Frequently Asked Question

What is the difference between a thread and a process in Linux?

Inside the kernel, threads and processes are the same thing: every schedulable entity is a task_struct. What differs is how much state they share. A new process (made by fork()) gets its own address space, file descriptor table, and signal handlers. A new thread (made by pthread_create(), which underneath calls clone() with sharing flags) shares the address space and file descriptors with the rest of the process but has its own stack and registers.

That's why all threads of a process see the same memory and can corrupt each other, but each is scheduled independently. The PID you see in ps is actually the thread group ID; each thread has its own TID. ps -eLf shows them.

Video

Further reading and video