synchronization Archive

Synchronized methods and blocks -III

Synchronized Blocks It allows execution of arbitrary code to be synchronized with lock of an arbitrary object. Once a thread reached on synchronized code block after acquiring lock on specified object, other threads will not be able to execute code block or any code requiring same object lock until it is not released by current

Synchronized methods and blocks -I

Java threads can share resources like memory space etc. Critical situation arise when only one thread at a time have access to shared resources. To handle similar situations, java provides high level concepts for synchronization to control access to shared resources. Locks A lock can be used to synchronize access to shared resources. Any thread