Suppose our code has 2 threads (A and B) have a reference to the same instance of this class somewhere:
public class MyValueHolder { private int value = 1;
Here's a simple way: just comment out the code for setValue. You can uncomment it after testing. Since in many cases like this a mechanism is needed to fake failures, it would be a good idea to build a general mechanism for all such cases.
setValue