Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <pthread.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- using namespace std;
- void *myFunction(void* arg)
- {
- char *s = (char*)arg;
- for(int i = 0; i<10; i++){
- cout<<i<<"\t"<<s<<"\n";
- }
- return NULL;
- }
- int main()
- {
- pthread_t thread1, thread2;
- int res1, res2;
- char* string1 = "THREAD 1";
- char* string2 = "THREAD 2";
- res1 = pthread_create(&thread1, NULL, myFunction, string1);
- pthread_join(thread1, NULL);
- res2 = pthread_create(&thread2, NULL, myFunction, string2);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement