I'm new to jmh and to understanding what happens behind threads and so on.
So, I started reading and got stuck on the @State annotation and shared vs unshared states.
I read this example : http://hg.openjdk.java.net/code-tools/jmh/file/ecd9e76155fe/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_03_States.java and have few questions about it.
First question, what is the exact role of state classes? to hold parameters? let's say I want to benchmark a program that encrypts a key in 2 different ways. Should i keep the key (a String object) in a state class which annotated with a specific state? or just keep the String object on the benchmark class? An explanation about this would be great.
Second question, why in the example above the unshared state class performance was much better than the shared one? How does the multithreaded state changes it?
I feel really obscured since i'm new to this thing and couldn't find an "explain me like i'm 5" examples for jmh and it's options.