equal
deleted
inserted
replaced
40 * @run main/othervm jdk.jfr.api.consumer.streaming.TestJVMExit |
40 * @run main/othervm jdk.jfr.api.consumer.streaming.TestJVMExit |
41 */ |
41 */ |
42 public class TestJVMExit { |
42 public class TestJVMExit { |
43 |
43 |
44 public static void main(String... args) throws Exception { |
44 public static void main(String... args) throws Exception { |
45 TestProcess process = new TestProcess("exit-application"); |
45 try (TestProcess process = new TestProcess("exit-application")) { |
46 AtomicInteger eventCounter = new AtomicInteger(); |
46 AtomicInteger eventCounter = new AtomicInteger(); |
47 try (EventStream es = EventStream.openRepository(process.getRepository())) { |
47 try (EventStream es = EventStream.openRepository(process.getRepository())) { |
48 // Start from first event in repository |
48 // Start from first event in repository |
49 es.setStartTime(Instant.EPOCH); |
49 es.setStartTime(Instant.EPOCH); |
50 es.onEvent(e -> { |
50 es.onEvent(e -> { |
51 if (eventCounter.incrementAndGet() == TestProcess.NUMBER_OF_EVENTS) { |
51 if (eventCounter.incrementAndGet() == TestProcess.NUMBER_OF_EVENTS) { |
52 process.exit(); |
52 process.exit(); |
53 } |
53 } |
54 }); |
54 }); |
55 es.start(); |
55 es.start(); |
|
56 } |
56 } |
57 } |
57 } |
58 } |
58 } |
59 } |