Home Help Java S Java Synchronized



Java Synchronized
Posted on: November 16, 2009 at 12:00 AM
The keyword synchronized entitled to the method or block is used to prevent it from being accessed simultaneously and save the state of an object from being corrupted.

Java Synchronized

     

The keyword synchronized entitled to the method or block is used to prevent it from being accessed simultaneously and save the state of an object from being corrupted. There are two ways to implement the keyword synchronized:

  1. Synchronized Methods:
    If you want a method of an object to be executed by one thread at a time then the method can be specified with the keyword synchronized. Method is needed to be synchronized in situation where method can manipulate the state of an object in ways that can corrupt the state if executed concurrently.
  2. Synchronized Blocks (Statements):
    It is the other way of synchronizing the code. In this approach, the block is provided an object to allow execution of block of code to be synchronized on the lock of this object.
     

Read more at:
 

http:/www.roseindia.net/java/thread/synchronization.shtml

Related Tags for Java Synchronized:


More Tutorials from this section

Ask Questions?    Discuss: Java Synchronized  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.