Thread
https://www.youtube.com/playlist?list=PL9IEJIKnBJjFZxuqyJ9JqVYmuFZHr7CFM
pthread_create -- the input thread fuction need take void pointer as input argument, and retrun void pointer.
pthread_join (*thread, *return_value_pointer)-- wait until the thread finish, can be used to pass the return value of thread to main function.
mutex/locks -- pthread_mutex_lock; https://www.geeksforgeeks.org/mutex-lock-for-linux-thread-synchronization/
thread pool -- to define a number of available thread to handle the message in the Task queue (FIFO) . The number of threads may be dynamically adjusted during the lifetime of an application based on the number of waiting tasks. The thread pool allows me to easily have a configurable limit for the number of tasks being running in parallel.
pthread_cond_t Condition variables -- are synchronization primitives that enable threads to wait until a particular condition occurs. pthread_cond_wait () is to ask the thread to wait, until pthread_cond_signal() is called
volatile -- block the compiler to fast running the code by assume some variable, pointer etc is unchanged as those variables could be changed by a thread, or SINGAL etc and compliler does not aware.
How can a single core processor run multiple tasks at once?