org.kuali.rice.core.util
Class ConcurrencyDetector
java.lang.Object
org.kuali.rice.core.util.ConcurrencyDetector
public class ConcurrencyDetector
- extends Object
Utility class that can be used to diagnose concurrency issues. When concurrency is detected
the default onConcurrencyDetected()
implementation logs an error and optionally the
stack traces (if trackStacktraces is enabled).
E.g.
private static final ConcurrencyDetector detector = new ConcurrencyDetector("Concurrency in Foo class");
public void questionableMethod() {
detector.enter();
try {
// method impl
} finally {
detector.exit();
}
}
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
Method Summary |
boolean |
enter()
|
void |
exit()
|
protected void |
onConcurrencyDetected()
Logs an error (and optionally stack traces) when concurrency is detected. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ACQUIRED_SEMAPHORE
private ThreadLocal<Boolean> ACQUIRED_SEMAPHORE
log
private final org.apache.log4j.Logger log
name
private final String name
trackStacktraces
private final boolean trackStacktraces
semaphore
private final Semaphore semaphore
entryPoint
private Throwable entryPoint
ConcurrencyDetector
public ConcurrencyDetector()
ConcurrencyDetector
public ConcurrencyDetector(String name)
ConcurrencyDetector
public ConcurrencyDetector(String name,
boolean trackStacktraces)
enter
public boolean enter()
exit
public void exit()
onConcurrencyDetected
protected void onConcurrencyDetected()
- Logs an error (and optionally stack traces) when concurrency is detected.
Subclasses may override for custom behavior.
Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.