Friday, May 29, 2009

Properties of synchronization

Synchronization is a process through which multiple threads share access to common objects. Java coordinates the actions of multiple threads using synchronized methods and statements. Following are the properties of synchronization:

  1. If a thread contains some locks and goes to sleep, then it does not release the locks.
  2. Only methods can be synchronized, not variables and constants.
  3. If two threads invoke the same method, then only one thread at a time can invoke a method.
  4. A thread can invoke a synchronized method on multiple objects.
  5. A class can have both synchronized and non-synchronized methods.
  6. If a class has synchronized and non-synchronized methods, then multiple threads can still access the non-synchronized methods of the class.

No comments:

Post a Comment