From 5a55e5c536a0531d9e15e85a72785c700277b9da Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 17 Nov 2018 23:49:48 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=D0=94=D0=97=20Threadpool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simpleThreadPool/pom.xml | 127 ++++++++++++++++++ .../simpleThreadPool/ConcurrencyTest.java | 68 ++++++++++ .../LightExecutionException.java | 3 + .../java/simpleThreadPool/LightFuture.java | 12 ++ .../simpleThreadPool/SupplierFuturePair.java | 15 +++ .../java/simpleThreadPool/ThreadPool.java | 9 ++ .../java/simpleThreadPool/ThreadPoolImpl.java | 44 ++++++ .../main/java/simpleThreadPool/Worker.java | 94 +++++++++++++ .../test/java/simpleThreadPool/PoolTest.java | 114 ++++++++++++++++ 9 files changed, 486 insertions(+) create mode 100644 simpleThreadPool/pom.xml create mode 100644 simpleThreadPool/src/main/java/simpleThreadPool/ConcurrencyTest.java create mode 100644 simpleThreadPool/src/main/java/simpleThreadPool/LightExecutionException.java create mode 100644 simpleThreadPool/src/main/java/simpleThreadPool/LightFuture.java create mode 100644 simpleThreadPool/src/main/java/simpleThreadPool/SupplierFuturePair.java create mode 100644 simpleThreadPool/src/main/java/simpleThreadPool/ThreadPool.java create mode 100644 simpleThreadPool/src/main/java/simpleThreadPool/ThreadPoolImpl.java create mode 100644 simpleThreadPool/src/main/java/simpleThreadPool/Worker.java create mode 100644 simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java diff --git a/simpleThreadPool/pom.xml b/simpleThreadPool/pom.xml new file mode 100644 index 0000000..02392e1 --- /dev/null +++ b/simpleThreadPool/pom.xml @@ -0,0 +1,127 @@ + + + + 4.0.0 + + 1 + simpleThreadPool + 0.0.1-SNAPSHOT + jar + + JCStress test sample + + + + + 3.0 + + + + + org.openjdk.jcstress + jcstress-core + ${jcstress.version} + + + junit + junit + 4.12 + test + + + + + UTF-8 + + + 0.4 + + + 1.8 + + + jcstress + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${javac.target} + ${javac.target} + ${javac.target} + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.2 + + + main + package + + shade + + + ${uberjar.name} + + + org.openjdk.jcstress.Main + + + META-INF/TestList + + + + + + + + + + diff --git a/simpleThreadPool/src/main/java/simpleThreadPool/ConcurrencyTest.java b/simpleThreadPool/src/main/java/simpleThreadPool/ConcurrencyTest.java new file mode 100644 index 0000000..5d4fc2e --- /dev/null +++ b/simpleThreadPool/src/main/java/simpleThreadPool/ConcurrencyTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017, Red Hat Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Oracle nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package simpleThreadPool; + +import java.util.Random; + +import org.openjdk.jcstress.annotations.*; +import org.openjdk.jcstress.infra.results.I_Result; + +// See jcstress-samples or existing tests for API introduction and testing guidelines + +@JCStressTest +// Outline the outcomes here. The default outcome is provided, you need to remove it: +@Outcome(id = "0", expect = Expect.ACCEPTABLE, desc = "Good outcome.") +@State +public class ConcurrencyTest { + + static ThreadPool pool = new ThreadPoolImpl(3); + Random rand = new Random(10); + + void filler(I_Result r) { + Integer rnd = rand.nextInt(); + LightFuture f = pool.submit(() -> rnd*rnd); + try { + r.r1 = rnd - f.get(); + } catch (LightExecutionException | InterruptedException e) { + int i = 1/0; + } + } + + + public void init() { + + } + + @Actor + public void actor1(I_Result r) { + filler(r); + } +} diff --git a/simpleThreadPool/src/main/java/simpleThreadPool/LightExecutionException.java b/simpleThreadPool/src/main/java/simpleThreadPool/LightExecutionException.java new file mode 100644 index 0000000..d30e7f4 --- /dev/null +++ b/simpleThreadPool/src/main/java/simpleThreadPool/LightExecutionException.java @@ -0,0 +1,3 @@ +package simpleThreadPool; + +public class LightExecutionException extends Exception {} diff --git a/simpleThreadPool/src/main/java/simpleThreadPool/LightFuture.java b/simpleThreadPool/src/main/java/simpleThreadPool/LightFuture.java new file mode 100644 index 0000000..b434d20 --- /dev/null +++ b/simpleThreadPool/src/main/java/simpleThreadPool/LightFuture.java @@ -0,0 +1,12 @@ +package simpleThreadPool; + +import java.util.function.Function; + +public interface LightFuture { + + public boolean isReady(); + + public R get() throws LightExecutionException, InterruptedException; + + public LightFuture thenApply(Function nextFunc); +} diff --git a/simpleThreadPool/src/main/java/simpleThreadPool/SupplierFuturePair.java b/simpleThreadPool/src/main/java/simpleThreadPool/SupplierFuturePair.java new file mode 100644 index 0000000..8183e78 --- /dev/null +++ b/simpleThreadPool/src/main/java/simpleThreadPool/SupplierFuturePair.java @@ -0,0 +1,15 @@ +package simpleThreadPool; + +import java.util.function.Supplier; + +import simpleThreadPool.Worker.LightFutureImpl; + +public class SupplierFuturePair { + Supplier supplier; + LightFutureImpl future; + + public SupplierFuturePair(Supplier suppl, LightFutureImpl fut) { + supplier = suppl; + future = fut; + } +} diff --git a/simpleThreadPool/src/main/java/simpleThreadPool/ThreadPool.java b/simpleThreadPool/src/main/java/simpleThreadPool/ThreadPool.java new file mode 100644 index 0000000..50ce89d --- /dev/null +++ b/simpleThreadPool/src/main/java/simpleThreadPool/ThreadPool.java @@ -0,0 +1,9 @@ +package simpleThreadPool; + +import java.util.function.Supplier; + +public interface ThreadPool { + public LightFuture submit(Supplier supp); + + public void shutdown(); +} diff --git a/simpleThreadPool/src/main/java/simpleThreadPool/ThreadPoolImpl.java b/simpleThreadPool/src/main/java/simpleThreadPool/ThreadPoolImpl.java new file mode 100644 index 0000000..a118d73 --- /dev/null +++ b/simpleThreadPool/src/main/java/simpleThreadPool/ThreadPoolImpl.java @@ -0,0 +1,44 @@ +package simpleThreadPool; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import java.util.function.Supplier; + +import simpleThreadPool.Worker.LightFutureImpl; + +public class ThreadPoolImpl implements ThreadPool{ + + private Queue tasks = new LinkedList<>(); + + private List pool = new ArrayList<>(); + + public ThreadPoolImpl(int nthreads) { + for (int i = 0; i < nthreads; i++) { + Thread t = new Thread(new Worker(tasks)); + pool.add(t); + t.start(); + } + } + + @Override + public LightFuture submit(Supplier supp) { + SupplierFuturePair pair = new SupplierFuturePair(supp, + new LightFutureImpl(this)); + + synchronized (tasks) { + tasks.add(pair); + tasks.notify(); + } + + return pair.future; + } + + @Override + public void shutdown() { + for (Thread t : pool) { + t.interrupt(); + } + } +} \ No newline at end of file diff --git a/simpleThreadPool/src/main/java/simpleThreadPool/Worker.java b/simpleThreadPool/src/main/java/simpleThreadPool/Worker.java new file mode 100644 index 0000000..e0845f8 --- /dev/null +++ b/simpleThreadPool/src/main/java/simpleThreadPool/Worker.java @@ -0,0 +1,94 @@ +package simpleThreadPool; + +import java.util.Queue; +import java.util.function.Function; + +public class Worker implements Runnable { + + private Queue queue; + + public Worker(Queue q) { + queue = q; + } + + static class LightFutureImpl implements LightFuture { + private volatile boolean isready; + private ThreadPool masterPool; + + private R result; + private LightExecutionException execExcept; + + public LightFutureImpl(ThreadPool tp) { + masterPool = tp; + } + + @Override + public boolean isReady() { + return isready; + } + + @Override + public R get() throws LightExecutionException, InterruptedException { + if (!isready) { + synchronized (this) { + while (!isready) { + this.wait(); + } + } + } + + if (execExcept != null) { + throw execExcept; + } + + return result; + } + + @Override + public LightFuture thenApply(Function nextFunc) { + return masterPool.submit(() -> { + R1 res = null; + try { + res = nextFunc.apply(get()); + } catch (Exception e) { + int i = 1 / 0; + } + return res; + }); + } + + } + + @Override + public void run() { +a: while (true) { + SupplierFuturePair workPair; + + synchronized (queue) { + while (queue.isEmpty()) { + try { + queue.wait(); + } catch (InterruptedException e) { + break a; + } + + } + workPair = queue.poll(); + } + + LightFutureImpl future = workPair.future; + synchronized (future) { + + try { + future.result = workPair.supplier.get(); + } catch (Exception e) { + future.execExcept = new LightExecutionException(); + } + + future.isready = true; + future.notifyAll(); + } + } + } + +} diff --git a/simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java b/simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java new file mode 100644 index 0000000..420319d --- /dev/null +++ b/simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java @@ -0,0 +1,114 @@ +package simpleThreadPool; + +import java.util.Collection; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +import org.junit.Assert; +import org.junit.Test; + +public class PoolTest extends Assert{ + + @Test + public void testBasicWorkability() throws LightExecutionException, InterruptedException { + ThreadPool pool = new ThreadPoolImpl(1); + LightFuture f1 = pool.submit(() -> 1); + LightFuture f2 = pool.submit(() -> 2); + assertEquals(Integer.valueOf(1), f1.get()); + assertEquals(Integer.valueOf(2), f2.get()); + } + + @Test + public void testFutureReady() throws LightExecutionException, InterruptedException { + + ThreadPool pool = new ThreadPoolImpl(1); + + Lock l1 = new ReentrantLock(); + l1.lock(); + + LightFuture f1 = pool.submit(() -> { + l1.lock(); + return 1; + }); + assertFalse(f1.isReady()); + + l1.unlock(); + f1.get(); + assertTrue(f1.isReady()); + } + + @Test + public void testMultipleThenApply() throws LightExecutionException, InterruptedException { + ThreadPool pool = new ThreadPoolImpl(1); + + LightFuture f = pool + .submit(() -> 1) + .thenApply((i) -> i + 1) + .thenApply((i) -> i + 1); + + assertEquals(Integer.valueOf(3), f.get()); + + } + + @Test(expected = LightExecutionException.class) + public void testException() throws LightExecutionException, InterruptedException { + ThreadPool pool = new ThreadPoolImpl(1); + pool.submit(() -> 1/0).get(); + } + + @Test(expected = LightExecutionException.class) + public void testExceptionThenApply() throws LightExecutionException, InterruptedException { + ThreadPool pool = new ThreadPoolImpl(1); + pool + .submit(() -> 1/0) + .thenApply((i) -> i + 1) + .get(); + } + + @Test(expected = LightExecutionException.class) + public void testInterruption() throws LightExecutionException, InterruptedException { + ThreadPool pool = new ThreadPoolImpl(1); + Object l = new Object(); + LightFuture f = pool + .submit(() -> { + try { + synchronized(l) { + while(true) + l.wait(); + } + } catch (InterruptedException e) { + int i = 1/0; + } + return 1; + }); + pool.shutdown(); + f.get(); + } + + @Test + public void testContainsNThreads() throws LightExecutionException, InterruptedException { + for (int nth = 1; nth < 50; nth++) { + ThreadPool pool = new ThreadPoolImpl(nth); + Lock l = new ReentrantLock(); + Collection thNames = new LinkedBlockingQueue<>(); + l.lock(); + LightFuture f = pool + .submit(() -> { + l.lock(); + thNames.add(Thread.currentThread().getName()); + return 1;}); + for (int j = 0; j < nth + 2; j++) { + f = f.thenApply((i) -> { + thNames.add(Thread.currentThread().getName()); + return 0;}); + + } + Thread.sleep(10); + l.unlock(); + f.get(); + assertEquals(nth + 3, thNames.size()); + assertEquals(nth, thNames.stream().distinct().count()); + } + } +} From 38e8f3f1d69a015c089152d511ffe21ac55cdd8a Mon Sep 17 00:00:00 2001 From: Anton Date: Sun, 18 Nov 2018 02:31:54 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20jcstress=20=D1=82=D0=B5=D1=81=D1=82.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++- .../simpleThreadPool/ConcurrencyTest.java | 68 ------------------- .../java/simpleThreadPool/SubmitGetTest.java | 48 +++++++++++++ .../java/simpleThreadPool/ThreadPoolImpl.java | 1 + .../test/java/simpleThreadPool/PoolTest.java | 7 ++ 5 files changed, 63 insertions(+), 69 deletions(-) delete mode 100644 simpleThreadPool/src/main/java/simpleThreadPool/ConcurrencyTest.java create mode 100644 simpleThreadPool/src/main/java/simpleThreadPool/SubmitGetTest.java diff --git a/README.md b/README.md index 4314260..3ac88cf 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ -# java_homeworks \ No newline at end of file +### Запуск jcstress + +''' +mvn clean install + +java -jar target/jcstress.jar +''' diff --git a/simpleThreadPool/src/main/java/simpleThreadPool/ConcurrencyTest.java b/simpleThreadPool/src/main/java/simpleThreadPool/ConcurrencyTest.java deleted file mode 100644 index 5d4fc2e..0000000 --- a/simpleThreadPool/src/main/java/simpleThreadPool/ConcurrencyTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2017, Red Hat Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Oracle nor the names of its contributors may be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ -package simpleThreadPool; - -import java.util.Random; - -import org.openjdk.jcstress.annotations.*; -import org.openjdk.jcstress.infra.results.I_Result; - -// See jcstress-samples or existing tests for API introduction and testing guidelines - -@JCStressTest -// Outline the outcomes here. The default outcome is provided, you need to remove it: -@Outcome(id = "0", expect = Expect.ACCEPTABLE, desc = "Good outcome.") -@State -public class ConcurrencyTest { - - static ThreadPool pool = new ThreadPoolImpl(3); - Random rand = new Random(10); - - void filler(I_Result r) { - Integer rnd = rand.nextInt(); - LightFuture f = pool.submit(() -> rnd*rnd); - try { - r.r1 = rnd - f.get(); - } catch (LightExecutionException | InterruptedException e) { - int i = 1/0; - } - } - - - public void init() { - - } - - @Actor - public void actor1(I_Result r) { - filler(r); - } -} diff --git a/simpleThreadPool/src/main/java/simpleThreadPool/SubmitGetTest.java b/simpleThreadPool/src/main/java/simpleThreadPool/SubmitGetTest.java new file mode 100644 index 0000000..a6bb41c --- /dev/null +++ b/simpleThreadPool/src/main/java/simpleThreadPool/SubmitGetTest.java @@ -0,0 +1,48 @@ +package simpleThreadPool; + +import java.util.Random; + +import org.openjdk.jcstress.annotations.*; +import org.openjdk.jcstress.infra.results.II_Result; +import org.openjdk.jcstress.infra.results.I_Result; + +@JCStressTest +@Outcome(id = "0, 0", expect = Expect.ACCEPTABLE, desc = "Good outcome.") +@State +public class SubmitGetTest { + + static ThreadPool pool = new ThreadPoolImpl(2); + Random rand = new Random(10); + + void filler(II_Result r) { + Integer rnd = rand.nextInt(); + LightFuture f1 = pool.submit(() -> rnd); + LightFuture f2 = f1.thenApply((i) -> i + 1); + try { + r.r1 = rnd - f1.get(); + r.r2 = rnd + 1 - f2.get(); + } catch (LightExecutionException | InterruptedException e) { + int i = 1/0; + } + } + + @Actor + public void actor1(II_Result r) { + filler(r); + } + + @Actor + public void actor2(II_Result r) { + filler(r); + } + + @Actor + public void actor3(II_Result r) { + filler(r); + } + + @Actor + public void actor4(II_Result r) { + filler(r); + } +} diff --git a/simpleThreadPool/src/main/java/simpleThreadPool/ThreadPoolImpl.java b/simpleThreadPool/src/main/java/simpleThreadPool/ThreadPoolImpl.java index a118d73..28676b1 100644 --- a/simpleThreadPool/src/main/java/simpleThreadPool/ThreadPoolImpl.java +++ b/simpleThreadPool/src/main/java/simpleThreadPool/ThreadPoolImpl.java @@ -17,6 +17,7 @@ public class ThreadPoolImpl implements ThreadPool{ public ThreadPoolImpl(int nthreads) { for (int i = 0; i < nthreads; i++) { Thread t = new Thread(new Worker(tasks)); + t.setDaemon(true); pool.add(t); t.start(); } diff --git a/simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java b/simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java index 420319d..4a5b05e 100644 --- a/simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java +++ b/simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java @@ -111,4 +111,11 @@ public void testContainsNThreads() throws LightExecutionException, InterruptedEx assertEquals(nth, thNames.stream().distinct().count()); } } + + @Test + public void testSameObjects() throws LightExecutionException, InterruptedException { + ThreadPool pool = new ThreadPoolImpl(1); + LightFuture f1 = pool.submit(() -> 1); + assertTrue(f1.get() == f1.get()); + } } From 22bde45a12ab0889e12d3860cc3dbf4040591bf5 Mon Sep 17 00:00:00 2001 From: Anton Date: Sun, 18 Nov 2018 02:34:47 +0300 Subject: [PATCH 3/4] readme edit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ac88cf..ae0cf7a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### Запуск jcstress -''' +``` mvn clean install java -jar target/jcstress.jar -''' +``` From 432624db64aead71cc34b55fe21d2839be98654b Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 21 Nov 2018 00:26:07 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D0=9A=D0=BE=D0=B5-=D0=B3=D0=B4=D0=B5=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=201/0=20=D0=BD=D0=B0?= =?UTF-8?q?=20RuntimeException?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simpleThreadPool/src/main/java/simpleThreadPool/Worker.java | 2 +- simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/simpleThreadPool/src/main/java/simpleThreadPool/Worker.java b/simpleThreadPool/src/main/java/simpleThreadPool/Worker.java index e0845f8..13bdfcb 100644 --- a/simpleThreadPool/src/main/java/simpleThreadPool/Worker.java +++ b/simpleThreadPool/src/main/java/simpleThreadPool/Worker.java @@ -51,7 +51,7 @@ public LightFuture thenApply(Function nextFunc) { try { res = nextFunc.apply(get()); } catch (Exception e) { - int i = 1 / 0; + throw new RuntimeException(); } return res; }); diff --git a/simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java b/simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java index 4a5b05e..c7f7f46 100644 --- a/simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java +++ b/simpleThreadPool/src/test/java/simpleThreadPool/PoolTest.java @@ -78,9 +78,9 @@ public void testInterruption() throws LightExecutionException, InterruptedExcept l.wait(); } } catch (InterruptedException e) { - int i = 1/0; + throw new RuntimeException(); } - return 1; + //return 1; }); pool.shutdown(); f.get();