1951 |
|
1000L, MILLISECONDS, |
1952 |
|
new SynchronousQueue<Runnable>()); |
1953 |
|
|
1954 |
+ |
/** |
1955 |
+ |
* Returns maximum number of tasks that can be submitted to given |
1956 |
+ |
* pool (with bounded queue) before saturation (when submission |
1957 |
+ |
* throws RejectedExecutionException). |
1958 |
+ |
*/ |
1959 |
+ |
static final int saturatedSize(ThreadPoolExecutor pool) { |
1960 |
+ |
BlockingQueue<Runnable> q = pool.getQueue(); |
1961 |
+ |
return pool.getMaximumPoolSize() + q.size() + q.remainingCapacity(); |
1962 |
+ |
} |
1963 |
+ |
|
1964 |
|
static <T> void shuffle(T[] array) { |
1965 |
|
Collections.shuffle(Arrays.asList(array), ThreadLocalRandom.current()); |
1966 |
|
} |