@Transactionalnot associated with synchronization. It just ensures that your thread succeeds or fails. Each hit has its own flow and its own success or failure.
I assume that you are worried about using shared data.
For example. If you have a class Foothat looks like this:
public class Foo {
private static boolean flag = true;
@Transactional
public void doSomething() {
flag = false;
}
}
In this case, it does not matter that you have many instances Foo, because they all use the same one flag.
Another scenario would be if you have one instance Foo(very common if you use something like Spring) and you have data that has been changed for that instance. You can look at the same example Fooand just remove staticfrom flag:
public class Foo {
private boolean flag = true;
@Transactional
public void doSomething() {
flag = false;
}
}
- . @Transactional.