mirror of
https://github.com/tiennm99/HDH.git
synced 2026-06-09 02:13:52 +00:00
18 lines
325 B
C
18 lines
325 B
C
#include <stdio.h>
|
|
#include <pthread.h>
|
|
void *hello(void *tid)
|
|
{
|
|
printf("Hello from thread %ld\n", (long)tid);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
pthread_t tid[10];
|
|
long i;
|
|
for (i = 0; i < 10; i++)
|
|
{
|
|
pthread_create(&tid[i], NULL, hello, (void *)i);
|
|
pthread_join(tid[i], NULL);
|
|
}
|
|
pthread_exit(NULL);
|
|
} |