1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
shared count := 0
shared mutex := semaphore(1)
main:
create_thread(thread_a)
create_thread(thread_b)
thread_a:
wait(mutex)
count := count + 1
signal(mutex)
thread_b:
wait(mutex)
count := count + 1
signal(mutex)