public class SyncThread<T> extends SpyThread
Constructor and Description |
---|
SyncThread(java.util.concurrent.CyclicBarrier b,
java.util.concurrent.Callable<T> c)
Get a SyncThread that will call the given callable when the given barrier
allows it past.
|
Modifier and Type | Method and Description |
---|---|
static <T> java.util.Collection<SyncThread<T>> |
getCompletedThreads(int num,
java.util.concurrent.Callable<T> callable)
Get a collection of SyncThreads that all began as close to the same time as
possible and have all completed.
|
static <T> int |
getDistinctResultCount(int num,
java.util.concurrent.Callable<T> callable)
Get the distinct result count for the given callable at the given
concurrency.
|
T |
getResult()
Get the result from the invocation.
|
void |
run()
Wait for the barrier, invoke the callable and capture the result or an
exception.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public SyncThread(java.util.concurrent.CyclicBarrier b, java.util.concurrent.Callable<T> c)
b
- the barrierc
- the callablepublic void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public T getResult() throws java.lang.Throwable
java.lang.Throwable
- if an error occurred when evaluating the callablepublic static <T> java.util.Collection<SyncThread<T>> getCompletedThreads(int num, java.util.concurrent.Callable<T> callable) throws java.lang.InterruptedException
T
- the result type of the SyncThreadnum
- the number of concurrent threads to executecallable
- the thing to calljava.lang.InterruptedException
- if we're interrupted during joinpublic static <T> int getDistinctResultCount(int num, java.util.concurrent.Callable<T> callable) throws java.lang.Throwable
T
- the type of the callablenum
- the concurrencycallable
- the callable to invokejava.lang.Throwable
- if an exception occurred in one of the invocationsCopyright © 2006-2009 Dustin Sallings, 2009-2013 Couchbase, Inc.