int id[2] = {0, 1};
pthread_t thread1;
pthread_t thread2;
- pthread_create(&thread1, NULL, thread_fun, (void*)&id[0]);
- pthread_create(&thread2, NULL, thread_fun, (void*)&id[1]);
+ pthread_create(&thread1, NULL, thread_fun, &id[0]);
+ pthread_create(&thread2, NULL, thread_fun, &id[1]);
fprintf(stderr, "All threads are started.\n");
pthread_join(thread1, NULL);
pthread_join(thread2, NULL);
int id[2] = {0, 1};
pthread_t thread1;
pthread_t thread2;
- pthread_create(&thread1, NULL, thread_fun1, (void*)&id[0]);
- pthread_create(&thread2, NULL, thread_fun2, (void*)&id[1]);
+ pthread_create(&thread1, NULL, thread_fun1, &id[0]);
+ pthread_create(&thread2, NULL, thread_fun2, &id[1]);
fprintf(stderr, "All threads are started.\n");
pthread_join(thread1, NULL);
pthread_join(thread2, NULL);
int ids[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // The identity of each thread (for debug messages)
for (int i = 0; i < ProducerCount; i++)
- pthread_create(&pro[i], NULL, (void*)&producer, (void*)&ids[i]);
+ pthread_create(&pro[i], NULL, producer, &ids[i]);
for (int i = 0; i < ConsumerCount; i++)
- pthread_create(&con[i], NULL, (void*)&consumer, (void*)&ids[i]);
+ pthread_create(&con[i], NULL, consumer, &ids[i]);
for (int i = 0; i < ProducerCount; i++)
pthread_join(pro[i], NULL);
int id[2] = {0, 1};
sthread_t thread1;
sthread_t thread2;
- sthread_create(&thread1, NULL, thread_fun, (void*)&id[0]);
- sthread_create(&thread2, NULL, thread_fun, (void*)&id[1]);
+ sthread_create(&thread1, NULL, thread_fun, &id[0]);
+ sthread_create(&thread2, NULL, thread_fun, &id[1]);
fprintf(stderr, "All threads are started.\n");
sthread_join(thread1, NULL);
sthread_join(thread2, NULL);