previous
|
start
|
next
Reentrant Locks
If you don't want to synchronize entire method bodies, you can use
reentrant locks
to synchronize specific bits of code:
aLock = new ReentrantLock();
. . .
aLock.lock();
try
{
protected code
}
finally
{
aLock.unlock();
}
previous
|
start
|
next