Thread Creation
Thread Creation
Thread 1: Thread 2:
lock(tree) lock(tree)
insert A to tree insert A to tree
unlock(tree) unlock(tree)
EPL222 - Labs 06/02/2020 3
A typical sequence in the use of a mutex is as
follows:
◦ Create and initialize a mutex variable
◦ Several threads attempt to lock the mutex
◦ Only one succeeds and that thread owns the mutex
◦ The owner thread performs some set of actions
◦ The owner unlocks the mutex
◦ Another thread acquires the mutex and repeats the
process
◦ Finally the mutex is destroyed