Visual Basic (3539)
About this site
Links to us
General :: Programming :: Java
This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Generated 20:01:31 on Oct 27, 2020
Thread synchronization in Java
Threads run in the same memory space and it is important that a thread does not inadvertently overwrite another's data. To control threads access to common data, Java offers the synchronized statement.
synchronized locks an object, preventing access to it, until it is unlocked.
When some other thread tries to access the locked object it remains blocked until the previous thread finishes and unlocks the object.
Locking and unlocking is done implicitely by Java. The programmer has only to use the synchronize statement:
|Most recent comments