This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
,page_url,subreddit,url,tld | |
0,https://www.reddit.com/r/java/,java,http://trane.io,trane.io | |
3,https://www.reddit.com/r/java/,java,https://www.niceideas.ch/roller2/badtrash/entry/bytecode-manipulation-with-javassist-for,www.niceideas.ch | |
4,https://www.reddit.com/r/java/,java,https://medium.com/@MelvinBlokhuijzen/spring-websocket-endpoints-integration-testing-180357b4f24c#.33kerqrrl,medium.com | |
5,https://www.reddit.com/r/java/,java,https://medium.com/@Codename_One/why-full-stack-matters-988020a7ea5b#.n1bszch84,medium.com | |
6,https://www.reddit.com/r/java/,java,https://shipilev.net/jvm-anatomy-park/2-transparent-huge-pages/,shipilev.net | |
8,https://www.reddit.com/r/java/,java,http://in.relation.to/2017/03/06/hibernate-community-newsletter-2017-5/,in.relation.to | |
9,https://www.reddit.com/r/java/,java,http://mydevgeek.com/spring-boot-rest-web-service-part-2-crud-operations-service-layers-assemblers-utility-classes/,mydevgeek.com | |
10,https://www.reddit.com/r/java/,java,https://youtu.be/wTPGW1PNy_Y,youtu.be | |
11,https://www.re |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAY_VERSION=2.1.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.*; | |
import org.testng.annotations.*; | |
import static org.testng.Assert.*; | |
public class CoreThreadTimeOut { | |
final int threadPoolSize = 10; | |
final int timeoutMillis = 30; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ThreadPoolExecutor threadPoolExecutor; | |
@BeforeMethod | |
void setUp() { | |
threadPoolExecutor = prepareThreadPoolExecutor(); | |
} | |
@AfterMethod | |
void tearDown() throws InterruptedException { | |
threadPoolExecutor.shutdown(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void threadsShouldBePresentAfterTimeoutIfWeDontAllowThreadTimeout() throws Throwable { | |
threadPoolExecutor.allowCoreThreadTimeOut(false); | |
CountDownLatch untilAllThreadsDone = startaBunchOfThreads(); | |
untilAllThreadsDone.await(); | |
waitUntilTimeoutOccurs(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void threadsShouldBePresentBeforeKeepAliveTimeKicks() throws Throwable { | |
CountDownLatch untilAllThreadsDone = startaBunchOfThreads(); | |
untilAllThreadsDone.await(); | |
waitBeforeTimeoutOccurs(); | |
assertEquals(countExecutorThreads(), threadPoolSize); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void shouldRemoveThreadsAfterCoreThreadTimeoutPeriod() throws Throwable { | |
CountDownLatch untilAllThreadsDone = startaBunchOfThreads(); | |
untilAllThreadsDone.await(); | |
waitUntilTimeoutOccurs(); | |
assertEquals(countExecutorThreads(), 0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
void shouldRemoveThreadsAfterCoreThreadTimeoutPeriod() throws Throwable { | |
ThreadPoolExecutor tpe = prepareTestThreadPool(threadCount, timeoutMillis); | |
long t0 = System.nanoTime(); | |
for (int i = 0; i < threadCount; i++) | |
tpe.submit(new Runnable() { public void run() {}}); | |
int count = countExecutorThreads(); | |
if (millisElapsedSince(t0) < timeoutMillis) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void test(String[] args) throws Throwable { | |
/* | |
* Prepare | |
*/ | |
ThreadPoolExecutor tpe = prepareTestThreadPool(threadCount, timeoutMillis); | |
long t0 = System.nanoTime(); | |
for (int i = 0; i < threadCount; i++) | |
tpe.submit(new Runnable() { public void run() {}}); |