Use synchronize to control access

http://ideone.com/ezMWzK