Open
Description
I think we have a problem in asyncJobs queue.
I see that this queue is used in shutdown, but, executorService.awaitTermination
can be a good alternative, right?
@RunWith(KikahaRunner.class)
public class ThreadsTest {
Threads threads = Threads.elasticPool();
final AtomicInteger counter = new AtomicInteger(0);
final int numberOfRunnables = 1000000;
@Test
@SneakyThrows
public void testThreads(){
int i = 0;
while ( i++ < numberOfRunnables )
threads.submit( counter::incrementAndGet );
Thread.sleep( 2000 );
val asyncJobsField = threads.getClass().getDeclaredField( "asyncJobs" );
asyncJobsField.setAccessible( true );
val asyncJobs = (Queue)asyncJobsField.get( threads );
assertEquals( numberOfRunnables, counter.get() );
assertEquals( 0, asyncJobs.size() ); // test fails here - size is 1000000!
}
}
Metadata
Metadata
Assignees
Labels
No labels