Skip to content

Instantly share code, notes, and snippets.

@Test
public void shouldRemoveThreadsAfterCoreThreadTimeoutPeriod() throws Throwable {
CountDownLatch untilAllThreadsDone = startaBunchOfThreads();
untilAllThreadsDone.await();
waitUntilTimeoutOccurs();
assertEquals(countExecutorThreads(), 0);
}
@Test
public void threadsShouldBePresentBeforeKeepAliveTimeKicks() throws Throwable {
CountDownLatch untilAllThreadsDone = startaBunchOfThreads();
untilAllThreadsDone.await();
waitBeforeTimeoutOccurs();
assertEquals(countExecutorThreads(), threadPoolSize);
}
@Test
public void threadsShouldBePresentAfterTimeoutIfWeDontAllowThreadTimeout() throws Throwable {
threadPoolExecutor.allowCoreThreadTimeOut(false);
CountDownLatch untilAllThreadsDone = startaBunchOfThreads();
untilAllThreadsDone.await();
waitUntilTimeoutOccurs();
private ThreadPoolExecutor threadPoolExecutor;
@BeforeMethod
void setUp() {
threadPoolExecutor = prepareThreadPoolExecutor();
}
@AfterMethod
void tearDown() throws InterruptedException {
threadPoolExecutor.shutdown();
import java.util.concurrent.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;
public class CoreThreadTimeOut {
final int threadPoolSize = 10;
final int timeoutMillis = 30;
wget -q http://downloads.typesafe.com/play/${PLAY_VERSION}/play-${PLAY_VERSION}.zip
unzip -q play-${PLAY_VERSION}.zip
play-${PLAY_VERSION}/play clean-all
play-${PLAY_VERSION}/play compile
play-${PLAY_VERSION}/play test
PLAY_VERSION=2.1.1
@tadas-subonis
tadas-subonis / java reddit links
Created March 16, 2017 16:48
Links found in Java Reddit Community
https://home-assistant.io/atom.xml
https://engineering.hellofresh.com/feed
http://hundredminutehack.blogspot.com/feeds/posts/default
http://rightfootin.blogspot.com/feeds/posts/default
https://devblogs.nvidia.com/parallelforall/feed
http://www.androidxu.com/feeds/posts/default
http://journalpanic.com/index.xml
http://robbygrodin.com/feed
https://snarky.ca/rss
https://www.ossblog.org/feed
http://andrewhfarmer.com/rss.xml
http://angularjs.blogspot.com/feeds/posts/default
http://browniefed.com/atom.xml
http://engineering.kapost.com/feed
http://ericlathrop.com/feed
http://feeds.feedburner.com/TheCodeDump
http://javascriptplayground.com/feed
http://jilles.me/rss
http://news.dartlang.org/feeds/posts/default
http://patriciopalladino.com/feed.xml