这么有意思的类居然不是public,还能不能愉快的玩耍了。。。
[code="java"]
/**
- Monitors a thread, interrupting it if it reaches the specified timeout.
- This works by sleeping until the specified timeout amount and then
- interrupting the thread being monitored. If the thread being monitored
- completes its work before being interrupted, it should
interrupt()
- the monitor thread.
- long timeoutInMillis = 1000;
- try {
- Thread monitor = ThreadMonitor.start(timeoutInMillis);
- // do some work here
- ThreadMonitor.stop(monitor);
- } catch (InterruptedException e) {
- // timed amount was reached
- }
- *
- @version $Id$ */[/code]