Skip to content

Commit

Permalink
#9237 remove handling of the race condition allowing to shrink below…
Browse files Browse the repository at this point in the history
… minThread + comment why that's safe

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed Mar 27, 2023
1 parent 4d6ad59 commit 1669716
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -641,21 +641,20 @@ public void testEnsureThreads() throws Exception
waitForThreads(tp, 3);
waitForIdle(tp, 0);

// We stop job3, the thread becomes idle, thread decides to shrink decrements the counters,
// and then blocks in removeThread().
// We stop job3, the thread becomes idle, thread decides to shrink, and then blocks in removeThread().
job3.stop();
assertTrue(enteredRemoveThread.await(5, TimeUnit.SECONDS));
waitForThreads(tp, 2);
waitForIdle(tp, 0);
waitForThreads(tp, 3);
waitForIdle(tp, 1);

// Executing job4 will start a new thread because we have 0 idle thread.
// Executing job4 will not start a new thread because we already have 1 idle thread.
RunningJob job4 = new RunningJob();
tp.execute(job4);

// Allow thread to exit from removeThread().
// The 4th thread is not actually started in our startThread() until tp.superStartThread() is called.
// Delay by 1000ms to check that ensureThreads is only starting one thread even though it is slow to start.
assertThat(started.get(), is(4));
assertThat(started.get(), is(3));
exitRemoveThread.countDown();
Thread.sleep(1000);

Expand Down

0 comments on commit 1669716

Please sign in to comment.