testWatch() — netty Function Reference
Architecture documentation for the testWatch() function in ThreadDeathWatcherTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 15d9eb4f_be4b_26cf_dd68_27b0df3b8239["testWatch()"] 4732e020_0588_e2dd_973d_3462f91e7c9e["ThreadDeathWatcherTest"] 15d9eb4f_be4b_26cf_dd68_27b0df3b8239 -->|defined in| 4732e020_0588_e2dd_973d_3462f91e7c9e style 15d9eb4f_be4b_26cf_dd68_27b0df3b8239 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/test/java/io/netty/util/ThreadDeathWatcherTest.java lines 34–78
@Test
@Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testWatch() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final Thread t = new Thread() {
@Override
public void run() {
for (;;) {
try {
Thread.sleep(1000);
} catch (InterruptedException ignore) {
break;
}
}
}
};
final Runnable task = new Runnable() {
@Override
public void run() {
if (!t.isAlive()) {
latch.countDown();
}
}
};
try {
ThreadDeathWatcher.watch(t, task);
fail("must reject to watch a non-alive thread.");
} catch (IllegalArgumentException e) {
// expected
}
t.start();
ThreadDeathWatcher.watch(t, task);
// As long as the thread is alive, the task should not run.
assertFalse(latch.await(750, TimeUnit.MILLISECONDS));
// Interrupt the thread to terminate it.
t.interrupt();
// The task must be run on termination.
latch.await();
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testWatch() do?
testWatch() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/ThreadDeathWatcherTest.java.
Where is testWatch() defined?
testWatch() is defined in common/src/test/java/io/netty/util/ThreadDeathWatcherTest.java at line 34.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free