er.extensions.eof
Class ERXGlobalLock
java.lang.Object
er.extensions.eof.ERXGlobalLock
- All Implemented Interfaces:
- com.webobjects.foundation.NSLocking
public class ERXGlobalLock
- extends java.lang.Object
- implements com.webobjects.foundation.NSLocking
Simple lock to sync access for multiple instances on one machine. This implementation
uses a lock file with the given name in the temp directory. In case of a VM crash, the file
is *not* deleted, so you have to do this yourself.
Additionally, you can't use it reliably on an NFS server. The lock otherwise behaves like an
NSRecursiveLock in that the same thread can re-lock as often as he wants.
App1:
NSLocking lock = ERXGlobalLock.lockForName("test");
lock.lock();
...
lock.unlock();
App2:
NSLocking lock = ERXGlobalLock.lockForName("test");
lock.lock();
...
lock.unlock();
- Author:
- ak
Fields inherited from interface com.webobjects.foundation.NSLocking |
_CLASS, OneCentury, OneDay, OneHour, OneMinute, OneSecond, OneWeek, OneYear |
Method Summary |
boolean |
cleanup()
Call this on startup. |
void |
lock()
|
static com.webobjects.foundation.NSLocking |
lockForName(java.lang.String name)
|
void |
unlock()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ERXGlobalLock
public ERXGlobalLock(java.lang.String name)
lock
public void lock()
- Specified by:
lock
in interface com.webobjects.foundation.NSLocking
unlock
public void unlock()
- Specified by:
unlock
in interface com.webobjects.foundation.NSLocking
cleanup
public boolean cleanup()
- Call this on startup.
lockForName
public static com.webobjects.foundation.NSLocking lockForName(java.lang.String name)
Copyright © 2002 – 2007 Project Wonder.