http://mail.openjdk.java.net/pipermail/jmh-dev/2014-August/001252.html
The spec for @Setup/@TearDown deliberately does not specify which threads are running these helper methods. Some scenarios, e.g. using @Setup/@TearDown like the JUnit's @BeforeClass/@AfterClass, require users to use Scope.Benchmark, but that might set them up to run @TearDown with the different thread than was used to run @Setup.
We might want to consider tracking the threads that had already executed the helper methods, e.g. by tracking the "ownership" over the @State class. Multiple things to consider when tracking the @State owner:
1. Do we share the owner across multiple Levels?
2. What do we do if the owner exits abruptly?
3. How do we handle the absence of paired @Setup/@TearDowns?
- ...?
The spec for @Setup/@TearDown deliberately does not specify which threads are running these helper methods. Some scenarios, e.g. using @Setup/@TearDown like the JUnit's @BeforeClass/@AfterClass, require users to use Scope.Benchmark, but that might set them up to run @TearDown with the different thread than was used to run @Setup.
We might want to consider tracking the threads that had already executed the helper methods, e.g. by tracking the "ownership" over the @State class. Multiple things to consider when tracking the @State owner:
1. Do we share the owner across multiple Levels?
2. What do we do if the owner exits abruptly?
3. How do we handle the absence of paired @Setup/@TearDowns?
- ...?