Home / Function/ testUnwatch() — netty Function Reference

testUnwatch() — netty Function Reference

Architecture documentation for the testUnwatch() function in ThreadDeathWatcherTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  d91df8dd_25e6_3b18_ea4a_8043d4ab40c4["testUnwatch()"]
  4732e020_0588_e2dd_973d_3462f91e7c9e["ThreadDeathWatcherTest"]
  d91df8dd_25e6_3b18_ea4a_8043d4ab40c4 -->|defined in| 4732e020_0588_e2dd_973d_3462f91e7c9e
  style d91df8dd_25e6_3b18_ea4a_8043d4ab40c4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/test/java/io/netty/util/ThreadDeathWatcherTest.java lines 80–121

    @Test
    @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
    public void testUnwatch() throws Exception {
        final AtomicBoolean run = new AtomicBoolean();
        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() {
                run.set(true);
            }
        };

        t.start();

        // Watch and then unwatch.
        ThreadDeathWatcher.watch(t, task);
        ThreadDeathWatcher.unwatch(t, task);

        // Interrupt the thread to terminate it.
        t.interrupt();

        // Wait until the thread dies.
        t.join();

        // Wait until the watcher thread terminates itself.
        assertTrue(ThreadDeathWatcher.awaitInactivity(Long.MAX_VALUE, TimeUnit.SECONDS));

        // And the task should not run.
        assertFalse(run.get());
    }

Domain

Subdomains

Frequently Asked Questions

What does testUnwatch() do?
testUnwatch() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/ThreadDeathWatcherTest.java.
Where is testUnwatch() defined?
testUnwatch() is defined in common/src/test/java/io/netty/util/ThreadDeathWatcherTest.java at line 80.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free