I made a very small program that creates two threads:
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
void *start()
{
printf("Am a new thread!\n");
printf("%d\n",pthread_self());
}
void main()
{
pthread_t thread_id1;
pthread_t thread_id2;
pthread_create(&thread_id1,NULL,start,NULL);
pthread_create(&thread_id2,NULL,start,NULL);
//pthread_join(thread_id,NULL);
sleep(30);
}
When I compile and run the program with:
gcc create.c -lpthread
./a.out
And I open a new terminal and try to view the threads, this is what I get:
ps -efL | grep a.out
root 1943 20158 1943 0 1 15:25 pts/4 00:00:00 ./a.out
root 1985 1889 1985 0 1 15:25 pts/5 00:00:00 grep --color=auto a.out
So why can't I see two thread ids here?