Home Help Java S Java Synchronized
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java Synchronized

Advertisement
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

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 16, 2009

Ask Questions?    Discuss: Java Synchronized  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com