Created
October 2, 2012 08:57
-
-
Save JavaDeveloper/3817541 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <pthread.h> | |
using namespace std; | |
void* thread_method(void* parameter){ | |
string s = *(string*)(parameter); | |
cout<<s<<endl; | |
} | |
int main(){ | |
pthread_t thread1, thread2; | |
string s1 = "thread s2", 1 = "thread 2"; | |
int res1 = pthread_create(&thread1, NULL, thread_method, (void*)&s1); | |
int res2 = pthread_create(&thread2, NULL, thread_method, (void*)&s2); | |
// waiting for threads | |
pthread_join(thread1, NULL); | |
pthread_join(thread2, NULL); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment