DelphiFAQ Home Search:
General :: Programming :: Java


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

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:

  // obj has to be an object reference
  synchronized (obj) 
   // statements


Generated 20:01:31 on Oct 27, 2020