##- # Author: Brian Tiffin # Dedicated to the public domain # # Date: August 2016 # Modified: 2016-10-03/22:59-0400 ##+ # # lock.icn, demonstrate mutual exclusive region locking # global x procedure main() mx := mutex() x := 0 t1 := thread incrementor(mx) t2 := thread incrementor(mx) every wait(t1 | t2) write("x = ", x) end procedure incrementor(m) lock(m) # a non atomic increment expression; fetch x, add to x, store x x := x + 1 unlock(m) end