aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs199/github_128/Application.java
blob: 9a4a7312fc18e24a5c91be27251475ab18abcaac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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 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();
  }

}