213 |
|
* getPoolSize returns number of started workers. |
214 |
|
*/ |
215 |
|
public void testGetPoolSize() { |
216 |
< |
ForkJoinPool p = new ForkJoinPool(1); |
216 |
> |
final CountDownLatch taskStarted = new CountDownLatch(1); |
217 |
> |
final CountDownLatch done = new CountDownLatch(1); |
218 |
> |
final ForkJoinPool p = new ForkJoinPool(1); |
219 |
|
try (PoolCleaner cleaner = cleaner(p)) { |
220 |
|
assertEquals(0, p.getActiveThreadCount()); |
221 |
< |
Future<String> future = p.submit(new StringTask()); |
221 |
> |
final Runnable task = new CheckedRunnable() { |
222 |
> |
public void realRun() throws InterruptedException { |
223 |
> |
taskStarted.countDown(); |
224 |
> |
assertEquals(1, p.getPoolSize()); |
225 |
> |
assertEquals(1, p.getActiveThreadCount()); |
226 |
> |
done.await(); |
227 |
> |
}}; |
228 |
> |
Future<?> future = p.submit(task); |
229 |
> |
await(taskStarted); |
230 |
|
assertEquals(1, p.getPoolSize()); |
231 |
+ |
assertEquals(1, p.getActiveThreadCount()); |
232 |
+ |
done.countDown(); |
233 |
|
} |
234 |
+ |
assertEquals(0, p.getPoolSize()); |
235 |
+ |
assertEquals(0, p.getActiveThreadCount()); |
236 |
|
} |
237 |
|
|
238 |
|
/** |