You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

517 B

Clone Thread Example

This C program uses clone() to create a new thread. It illustrates, that the new thread shares the same data and heap segment. The main process creates a new thread with clone. clone() will execute a function that prints a buffer to stdout and then waits 2 seconds and does it again. In the meantime, the main thread changes the content of the buffer. That the child thread prints different things shows that they are not seperate processes.

Compile

make

Run

./main