Skip to content

Commit

Permalink
tiny improve
Browse files Browse the repository at this point in the history
  • Loading branch information
Linary committed Jan 30, 2021
1 parent 7ca72ca commit 618678a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ public class PausableScheduledThreadPool extends ScheduledThreadPoolExecutor {

private volatile boolean paused = false;

public PausableScheduledThreadPool(int corePoolSize) {
super(corePoolSize);
}

public PausableScheduledThreadPool(int corePoolSize,
ThreadFactory factory) {
super(corePoolSize, factory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class PausableScheduledThreadPoolTest {
@Test
public void testscheduleWithFixedDelay() throws InterruptedException {
PausableScheduledThreadPool executor =
ExecutorUtil.newPausableScheduledThreadPool(2, "test");
ExecutorUtil.newPausableScheduledThreadPool("test");
AtomicInteger counter = new AtomicInteger(0);
executor.scheduleWithFixedDelay(() -> {
System.out.println("counter: " + counter.incrementAndGet());
Expand All @@ -52,6 +52,9 @@ public void testscheduleWithFixedDelay() throws InterruptedException {
Thread.sleep(2000);
Assert.assertEquals(3, counter.get());

// pause again
executor.pauseSchedule();

executor.shutdown();
executor.awaitTermination(3, TimeUnit.SECONDS);
}
Expand All @@ -77,6 +80,9 @@ public void testscheduleWithFixedRate() throws InterruptedException {
Thread.sleep(2000);
Assert.assertEquals(4, counter.get());

// pause again
executor.pauseSchedule();

executor.shutdownNow();
executor.awaitTermination(3, TimeUnit.SECONDS);
}
Expand Down

0 comments on commit 618678a

Please sign in to comment.