Skip to content

Commit

Permalink
Reuse BasicThreadFactory in test
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 18, 2024
1 parent a3d2ace commit b56b475
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.concurrent.TimeUnit;

import org.apache.commons.beanutils2.WrapDynaClass;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
Expand All @@ -54,15 +55,11 @@ protected int random(final int max) {
*/
@Timeout(value = 60, unit = TimeUnit.SECONDS)
@Test
public void test_concurrent() throws InterruptedException {
public void testConcurrent() throws InterruptedException {
final List<Class<?>> classList = Arrays.asList(Map.class, HashMap.class, Collections.class, Arrays.class, Collection.class, Set.class, ArrayList.class,
List.class, HashSet.class);
// All daemon threads.
final ExecutorService executor = Executors.newFixedThreadPool(100, r -> {
final Thread thread = new Thread(r);
thread.setDaemon(true);
return thread;
});
final ExecutorService executor = Executors.newFixedThreadPool(100, new BasicThreadFactory.Builder().daemon(true).build());
try {
// Loop _may_ hang without fix.
for (int i = 1; i < 10_000_000; i++) {
Expand Down

0 comments on commit b56b475

Please sign in to comment.