Use java.util.concurrent package
Lock mylock;
try
{
mylock.lock();
//critical section
}
finally{
mylock.unlock();
}
Also:
try a lock with a timeout trylock()
wait for some condition: condition.await()
these could come handy to avoid the deadlock situations.
Use java.util.concurrent package Also: This can be achived using the volatile keyword this will be more useful. When multiple threads using the same variable .
Lock mylock;
try
{
mylock.lock();
//critical section
}
finally{
mylock.unlock();
}
try a lock with a timeout trylock()
wait for some condition: condition.await()
these could come handy to avoid the deadlock situations.
No comments:
Post a Comment