diff options
Diffstat (limited to 'tests/bugs198/github_128/Application.java')
-rw-r--r-- | tests/bugs198/github_128/Application.java | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/tests/bugs198/github_128/Application.java b/tests/bugs198/github_128/Application.java index d42b0fee4..9a4a7312f 100644 --- a/tests/bugs198/github_128/Application.java +++ b/tests/bugs198/github_128/Application.java @@ -1,14 +1,42 @@ +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + public class Application { + static int proceedTimesOuter; + static int proceedTimesInner; + static boolean useThreadPool = false; + static ExecutorService executorService = Executors.newFixedThreadPool(2); + @MarkerA @MarkerB public void doSomething() { System.out.println(" Doing something"); } - public static void main(String[] args) throws InterruptedException { - MarkerAAspect.proceedTimes = Integer.parseInt(args[0]); - MarkerBAspect.proceedTimes = Integer.parseInt(args[1]); + public static void main(String[] args) throws ExecutionException, InterruptedException { + proceedTimesOuter = Integer.parseInt(args[0]); + proceedTimesInner = Integer.parseInt(args[1]); + useThreadPool = args.length > 2 && args[2].trim().equalsIgnoreCase("true"); + if (useThreadPool) + prepopulateFixedThreadPool(); + new Application().doSomething(); Thread.sleep(500); } + + private static void prepopulateFixedThreadPool() throws InterruptedException, ExecutionException { + Future<?> future1 = executorService.submit(() -> { + try { Thread.sleep(250); } + catch (InterruptedException e) { e.printStackTrace(); } + }); + Future<?> future2 = executorService.submit(() -> { + try { Thread.sleep(250); } + catch (InterruptedException e) { e.printStackTrace(); } + }); + future1.get(); + future2.get(); + } + } |