public synchronized void myMethod() {
boolean hasLock = false;
Object obj = new Object();
// Determine if current thread has lock for obj
hasLock = Thread.holdsLock(obj); // false
synchronized (obj) {
hasLock = Thread.holdsLock(obj); // true
}
}
Wednesday, June 24, 2009
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment