Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- int thread(int num) {
- Sleep(rand()%10000); // Sleep randomly between 0 and 10 seconds
- printf("Thread %d finished\n",num); // Print and exit
- }
- int main(int argc,char** argv) {
- int i=0;
- for (i=0; i<10; i++) {
- CreateThread(NULL,0,thread,{i},0); // Create the thread, notice that this will happen instantly
- }
- Sleep(15000); // Give the processes time to finish
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement