8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6458662
27 * @summary poolSize might shrink below corePoolSize after timeout
28 * @library /lib/testlibrary/
29 * @author Martin Buchholz
30 */
31
32 import static java.util.concurrent.TimeUnit.MILLISECONDS;
33
34 import java.util.concurrent.CyclicBarrier;
35 import java.util.concurrent.SynchronousQueue;
36 import java.util.concurrent.ThreadPoolExecutor;
37 import jdk.testlibrary.Utils;
38
39 public class TimeOutShrink {
40 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
41 static final long KEEPALIVE_MS = 12L;
42
43 static void checkPoolSizes(ThreadPoolExecutor pool,
44 int size, int core, int max) {
45 equal(pool.getPoolSize(), size);
46 equal(pool.getCorePoolSize(), core);
47 equal(pool.getMaximumPoolSize(), max);
48 }
49
50 private static void realMain(String[] args) throws Throwable {
51 final int n = 4;
52 final CyclicBarrier barrier = new CyclicBarrier(2*n+1);
53 final ThreadPoolExecutor pool
54 = new ThreadPoolExecutor(n, 2*n,
55 KEEPALIVE_MS, MILLISECONDS,
56 new SynchronousQueue<Runnable>());
57 final Runnable r = new Runnable() { public void run() {
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6458662
27 * @summary poolSize might shrink below corePoolSize after timeout
28 * @library /test/lib
29 * @author Martin Buchholz
30 */
31
32 import static java.util.concurrent.TimeUnit.MILLISECONDS;
33
34 import java.util.concurrent.CyclicBarrier;
35 import java.util.concurrent.SynchronousQueue;
36 import java.util.concurrent.ThreadPoolExecutor;
37 import jdk.test.lib.Utils;
38
39 public class TimeOutShrink {
40 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
41 static final long KEEPALIVE_MS = 12L;
42
43 static void checkPoolSizes(ThreadPoolExecutor pool,
44 int size, int core, int max) {
45 equal(pool.getPoolSize(), size);
46 equal(pool.getCorePoolSize(), core);
47 equal(pool.getMaximumPoolSize(), max);
48 }
49
50 private static void realMain(String[] args) throws Throwable {
51 final int n = 4;
52 final CyclicBarrier barrier = new CyclicBarrier(2*n+1);
53 final ThreadPoolExecutor pool
54 = new ThreadPoolExecutor(n, 2*n,
55 KEEPALIVE_MS, MILLISECONDS,
56 new SynchronousQueue<Runnable>());
57 final Runnable r = new Runnable() { public void run() {
|