Questions: Thread Creation and Lifecycle

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A server creates one new joinable thread per request using pthread_create() but never calls pthread_join(). After serving thousands of requests, what is the likely consequence?

AThe server crashes immediately when thread limit is reached, because the OS kills orphaned threads
BPerformance improves because threads exit and free themselves automatically once the function returns
CThread resources (stack, metadata) accumulate without being freed, eventually exhausting memory or hitting OS thread limits
DThe threads keep running in the background, completing their work but logging errors
Question 2 Multiple Choice

Which of the following is NOT shared between threads in the same process?

AHeap memory (dynamically allocated objects)
BOpen file descriptors
CEach thread's own call stack
DThe program's code (text segment)
Question 3 True / False

A joinable thread that has called pthread_exit() and terminated still holds memory resources until another thread calls pthread_join() on it.

TTrue
FFalse
Question 4 True / False

Calling pthread_exit() in a thread is equivalent to calling pthread_detach() on it — both cause the thread's resources to be freed immediately upon exit.

TTrue
FFalse
Question 5 Short Answer

Explain the difference between a joinable and a detached thread in POSIX. What are the resource consequences of each design, and when would you choose detached over joinable?

Think about your answer, then reveal below.