Skip to content

Instantly share code, notes, and snippets.

@JavaDeveloper
Created October 2, 2012 08:57
Show Gist options
  • Save JavaDeveloper/3817541 to your computer and use it in GitHub Desktop.
Save JavaDeveloper/3817541 to your computer and use it in GitHub Desktop.
#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