public class Test010Lingering extends RandomizedTest
Executors framework where background
ThreadFactory is not published if not given explicitly.
To handle such situations RandomizedRunner needs to know if it should
await background thread to complete (and for how long) or if it should allow
them to "leak" safely and not complain. All this can be declared with a set
of annotations starting with ThreadLeak* prefix.
We can use ThreadLeakLingering annotation instead of explicitly using
Thread.join() sometimes. For example, Test009ThreadLeaks.leftOverThread()
can be rewritten as shown in lingerForLeftOverThread().
The same annotation can be used to wait for background threads
which we don't have any control on, but we know they will eventually terminate.
For example, a terminated Executor does not wait (join) with its slave
threads so lingering here is required. This is shown in method executorLeak(). This
method will fail (from time to time, it isn't guaranteed) if no lingering time is given.
There are other annotations for advanced control of thread leaks and their outcomes, check out the javadocs in the links below.
ISO8859_1, SYSPROP_MULTIPLIER, US_ASCII, UTF16, UTF32, UTF8| Constructor and Description |
|---|
Test010Lingering() |
| Modifier and Type | Method and Description |
|---|---|
void |
executorLeak() |
void |
lingerForLeftOverThread() |
$, $$, assumeFalse, assumeFalse, assumeNoException, assumeNoException, assumeNotNull, assumeTrue, assumeTrue, atLeast, atMost, between, closeAfterSuite, closeAfterTest, frequently, getContext, getRandom, globalTempDir, isNightly, iterations, multiplier, newServerSocket, newTempDir, newTempDir, newTempFile, newTempFile, randomAsciiOfLength, randomAsciiOfLengthBetween, randomBoolean, randomByte, randomDouble, randomFloat, randomFrom, randomFrom, randomGaussian, randomInt, randomInt, randomIntBetween, randomLocale, randomLong, randomRealisticUnicodeOfCodepointLength, randomRealisticUnicodeOfCodepointLengthBetween, randomRealisticUnicodeOfLength, randomRealisticUnicodeOfLengthBetween, randomShort, randomTimeZone, randomUnicodeOfCodepointLength, randomUnicodeOfCodepointLengthBetween, randomUnicodeOfLength, randomUnicodeOfLengthBetween, rarely, scaledRandomIntBetween, sleep, systemPropertyAsBoolean, systemPropertyAsDouble, systemPropertyAsFloat, systemPropertyAsInt, systemPropertyAsLongassertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, failCopyright © 2011-2012 Carrot Search s.c.. All Rights Reserved.