12 |
|
* @modules java.management |
13 |
|
* @build * |
14 |
|
* @run junit/othervm/timeout=1000 -Djsr166.testImplementationDetails=true JSR166TestCase |
15 |
+ |
* @run junit/othervm/timeout=1000 -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 -Djsr166.testImplementationDetails=true JSR166TestCase |
16 |
|
*/ |
17 |
|
|
18 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
59 |
|
import java.util.concurrent.RecursiveTask; |
60 |
|
import java.util.concurrent.RejectedExecutionHandler; |
61 |
|
import java.util.concurrent.Semaphore; |
62 |
+ |
import java.util.concurrent.SynchronousQueue; |
63 |
|
import java.util.concurrent.ThreadFactory; |
64 |
|
import java.util.concurrent.ThreadPoolExecutor; |
65 |
|
import java.util.concurrent.TimeoutException; |
521 |
|
// Java9+ test classes |
522 |
|
if (atLeastJava9()) { |
523 |
|
String[] java9TestClassNames = { |
524 |
< |
// Currently empty, but expecting varhandle tests |
524 |
> |
"ExecutorCompletionService9Test", |
525 |
|
}; |
526 |
|
addNamedTestClasses(suite, java9TestClassNames); |
527 |
|
} |
979 |
|
* Uninteresting threads are filtered out. |
980 |
|
*/ |
981 |
|
static void dumpTestThreads() { |
982 |
+ |
SecurityManager sm = System.getSecurityManager(); |
983 |
+ |
if (sm != null) { |
984 |
+ |
try { |
985 |
+ |
System.setSecurityManager(null); |
986 |
+ |
} catch (SecurityException giveUp) { |
987 |
+ |
return; |
988 |
+ |
} |
989 |
+ |
} |
990 |
+ |
|
991 |
|
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); |
992 |
|
System.err.println("------ stacktrace dump start ------"); |
993 |
|
for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) { |
1005 |
|
System.err.print(info); |
1006 |
|
} |
1007 |
|
System.err.println("------ stacktrace dump end ------"); |
1008 |
+ |
|
1009 |
+ |
if (sm != null) System.setSecurityManager(sm); |
1010 |
|
} |
1011 |
|
|
1012 |
|
/** |
1846 |
|
} catch (NoSuchElementException success) {} |
1847 |
|
assertFalse(it.hasNext()); |
1848 |
|
} |
1849 |
+ |
|
1850 |
+ |
public <T> Callable<T> callableThrowing(final Exception ex) { |
1851 |
+ |
return new Callable<T>() { public T call() throws Exception { throw ex; }}; |
1852 |
+ |
} |
1853 |
+ |
|
1854 |
+ |
public Runnable runnableThrowing(final RuntimeException ex) { |
1855 |
+ |
return new Runnable() { public void run() { throw ex; }}; |
1856 |
+ |
} |
1857 |
+ |
|
1858 |
+ |
/** A reusable thread pool to be shared by tests. */ |
1859 |
+ |
static final ExecutorService cachedThreadPool = |
1860 |
+ |
new ThreadPoolExecutor(0, Integer.MAX_VALUE, |
1861 |
+ |
1000L, MILLISECONDS, |
1862 |
+ |
new SynchronousQueue<Runnable>()); |
1863 |
+ |
|
1864 |
|
} |