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() {}}); |
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 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) | |
assertEquals(count, threadCount); |
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 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) | |
assertEquals(count, threadCount); |
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 { | |
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) | |
equal(count, threadCount); |
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
import java.util.concurrent.*; | |
import org.testng.annotations.*; | |
import static org.testng.Assert.*; | |
public class CoreThreadTimeOut { | |
final int threadCount = 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
import java.util.concurrent.*; | |
public class CoreThreadTimeOut { | |
static class IdentifiableThreadFactory implements ThreadFactory { | |
static ThreadFactory defaultThreadFactory | |
= Executors.defaultThreadFactory(); | |
public Thread newThread(Runnable r) { | |
Thread t = defaultThreadFactory.newThread(r); |
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.*; | |
public class CoreThreadTimeOut { | |
static class IdentifiableThreadFactory implements ThreadFactory { | |
static ThreadFactory defaultThreadFactory | |
= Executors.defaultThreadFactory(); | |
public Thread newThread(Runnable r) { | |
Thread t = defaultThreadFactory.newThread(r); |
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
class OrderPlacedEvent { | |
private Order order; | |
} | |
class ShopSellerService { | |
@Inject | |
private EventBus eventBus; | |
public void sell(Order order) { |
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
class OrderPlacedEvent { | |
private Order order; | |
} | |
class ShopSellerService { | |
@Inject | |
private EventBus eventBus; | |
public void sell(Order order) { |