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 6576792
27 * @summary non-idle worker threads should not be interrupted
28 * @library /lib/testlibrary/
29 */
30
31 import static java.util.concurrent.TimeUnit.MILLISECONDS;
32
33 import java.util.concurrent.CountDownLatch;
34 import java.util.concurrent.SynchronousQueue;
35 import java.util.concurrent.ThreadPoolExecutor;
36 import java.util.concurrent.TimeUnit;
37 import jdk.testlibrary.Utils;
38
39 public class SelfInterrupt {
40 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
41
42 void test(String[] args) throws Throwable {
43 final int n = 100;
44 final ThreadPoolExecutor pool =
45 new ThreadPoolExecutor(n, n, 1L, TimeUnit.NANOSECONDS,
46 new SynchronousQueue<Runnable>());
47 final CountDownLatch startingGate = new CountDownLatch(n);
48 final CountDownLatch finishLine = new CountDownLatch(n);
49 equal(pool.getCorePoolSize(), n);
50 equal(pool.getPoolSize(), 0);
51 for (int i = 0; i < n; i++)
52 pool.execute(new Runnable() { public void run() {
53 try {
54 startingGate.countDown();
55 startingGate.await();
56 equal(pool.getPoolSize(), n);
57 pool.setCorePoolSize(n);
|
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 6576792
27 * @summary non-idle worker threads should not be interrupted
28 * @library /test/lib
29 */
30
31 import static java.util.concurrent.TimeUnit.MILLISECONDS;
32
33 import java.util.concurrent.CountDownLatch;
34 import java.util.concurrent.SynchronousQueue;
35 import java.util.concurrent.ThreadPoolExecutor;
36 import java.util.concurrent.TimeUnit;
37 import jdk.test.lib.Utils;
38
39 public class SelfInterrupt {
40 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
41
42 void test(String[] args) throws Throwable {
43 final int n = 100;
44 final ThreadPoolExecutor pool =
45 new ThreadPoolExecutor(n, n, 1L, TimeUnit.NANOSECONDS,
46 new SynchronousQueue<Runnable>());
47 final CountDownLatch startingGate = new CountDownLatch(n);
48 final CountDownLatch finishLine = new CountDownLatch(n);
49 equal(pool.getCorePoolSize(), n);
50 equal(pool.getPoolSize(), 0);
51 for (int i = 0; i < n; i++)
52 pool.execute(new Runnable() { public void run() {
53 try {
54 startingGate.countDown();
55 startingGate.await();
56 equal(pool.getPoolSize(), n);
57 pool.setCorePoolSize(n);
|