Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "thread.h"
- #define NUM_THREADS 10
- using namespace std;
- int x = 10;
- /*
- void *PrintHello(void *threadid)
- {
- long tid;
- tid = (long)threadid;
- printf("Hello World! It's me, thread #%ld!\n", tid);
- ++x;
- pthread_exit(NULL);
- }
- int main (int argc, char *argv[])
- {
- pthread_t threads[NUM_THREADS];
- int rc;
- long t;
- for(t=0; t<NUM_THREADS; t++){
- printf("In main: creating thread %ld\n", t);
- rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
- if (rc){
- printf("ERROR; return code from pthread_create() is %d\n", rc);
- //exit(-1);
- }
- }
- cout << x << endl;
- pthread_exit(NULL);
- }
- */
- void* foo(void *threadId){
- for(int i=0; i<200; ++i)
- printf("lol");
- pthread_exit(NULL);
- }
- void* foo2(void *threadId){
- for(int i=0; i<200; ++i)
- printf("nab");
- pthread_exit(NULL);
- }
- int main(){
- Thread t1, t2;
- t1.start();
- t2.start();
- t1.stop();
- t2.stop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement