Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java heckj object lock

Lock lock = new ReentrantLock();
......
if (lock.tryLock())
{
    // Got the lock
    try
    {
        // Process record
    }
    finally
    {
        // Make sure to unlock so that we don't cause a deadlock
        lock.unlock();
    }
}
else
{
    // Someone else had the lock, abort
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #java #heckj #object #lock
ADD COMMENT
Topic
Name
9+9 =