Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7901011

@Setup/@TearDown methods should be run with the same threads

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • tools
    • None
    • jmh

      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?
       - ...?

            shade Aleksey Shipilev
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: