This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes synchronized Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "synchronized" Watch "synchronized" New topic
Author

synchronized

TAHA ALI
Greenhorn

Joined: Jul 14, 2003
Posts: 11
hi,
i m TahaAlimy question is that what is synchronized..
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Hello Taha, I'm going to move this post to the Java Beginners forum where it can be properly answered.
Also, you may want to do a search on that forum for the word "synchronized", I'm sure you'll find many posts.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Taha,
Welcome to JavaRanch. Java is a multi-threaded language, which means that in a single application you can have many threads of execution running at the same time. Let's say you have a class which has a reference to some object which can be changed when certain methods are called. What do you think would happen to that object if five threads were allowed to gain access to it at the same time? It would soon become corrupted. That is where synchronized comes in. Using the synchronized keyword on a method or an object guarantees that only one thread at a time can gain access to that block of code. Here are a couple of examples:


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
wood burning stoves
 
subject: synchronized
 
Similar Threads
Blocking I/O using Iterator()
Why am I getting NullPointerException?
synchronized context
THREAD
Vector V/s ArrayList