|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.util.ThreadMonitor.UnitTest.ListenerTest
private static class ThreadMonitor.UnitTest.ListenerTest
Simple ThreadMonitorListener implementation meant for test purposes:
it prints all events to System.out
(except for onThreadState
, which outputs to pw
),
it uses barrier
to coordinate actions with the main thread,
and onThreadState
can be configured to deliberately throw a RuntimeException when makeFail
called.
Field Summary | |
---|---|
private CyclicBarrier |
barrier
|
private boolean |
fail
|
private long |
instanceId
|
private static AtomicLong |
instanceIdNext
|
private PrintWriter |
pw
|
Constructor Summary | |
---|---|
private |
ThreadMonitor.UnitTest.ListenerTest()
|
Method Summary | |
---|---|
private void |
await()
Waits for the main thread to reach a common barrier point with the Timer thread executing this method. |
void |
close()
|
private void |
makeFail()
|
void |
onDeadlocked(String state)
Called whenever the associated ThreadMonitor instance first detects deadlock when previously it had detected no deadlock. |
void |
onMonitoringError(Throwable t)
Called when the associated ThreadMonitor instance has detected some error while monitoring. |
void |
onMonitoringStarted()
Called when the associated ThreadMonitor instance has just started monitoring. |
void |
onMonitoringStopped()
Called when the associated ThreadMonitor instance has just stopped monitoring. |
void |
onNotDeadlocked(String state)
Called whenever the associated ThreadMonitor instance first detects no deadlock when previously it had detected deadlock. |
void |
onThreadState(String state)
Called whenever the associated ThreadMonitor instance has measured a new thread state. |
private void |
setBarrier(CyclicBarrier barrier)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static AtomicLong instanceIdNext
private final long instanceId
private final PrintWriter pw
private CyclicBarrier barrier
private boolean fail
Constructor Detail |
---|
private ThreadMonitor.UnitTest.ListenerTest() throws IOException
IOException
Method Detail |
---|
public void onMonitoringStarted()
ThreadMonitorListener
onMonitoringStarted
in interface ThreadMonitorListener
public void onMonitoringStopped()
ThreadMonitorListener
onMonitoringStopped
in interface ThreadMonitorListener
public void onMonitoringError(Throwable t)
ThreadMonitorListener
onMonitoringError
in interface ThreadMonitorListener
t
- the Throwable which caused the errorpublic void onThreadState(String state)
ThreadMonitorListener
onThreadState
in interface ThreadMonitorListener
state
- the entire thread state which was just measuredpublic void onDeadlocked(String state) throws RuntimeException
ThreadMonitorListener
onDeadlocked
in interface ThreadMonitorListener
state
- the thread state of just the deadlocked threads
RuntimeException
public void onNotDeadlocked(String state)
ThreadMonitorListener
onNotDeadlocked
in interface ThreadMonitorListener
state
- the entire thread state which was just measuredprivate void setBarrier(CyclicBarrier barrier)
private void await()
private void makeFail()
public void close()
close
in interface Closeable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |