File tree 1 file changed +7
-3
lines changed
balking/src/test/java/com/iluwatar/balking 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 35
35
*/
36
36
public class WashingMachineTest {
37
37
38
- private volatile WashingMachineState machineStateGlobal ;
38
+ private WashingMachineState machineStateGlobal ;
39
39
40
40
@ Test
41
41
public void wash () throws Exception {
42
42
WashingMachine washingMachine = new WashingMachine ();
43
43
ExecutorService executorService = Executors .newFixedThreadPool (2 );
44
44
executorService .execute (() -> {
45
45
washingMachine .wash ();
46
- machineStateGlobal = washingMachine .getWashingMachineState ();
46
+ if (machineStateGlobal ==null ) {
47
+ machineStateGlobal = washingMachine .getWashingMachineState ();
48
+ }
47
49
});
48
50
executorService .execute (() -> {
49
51
washingMachine .wash ();
50
- machineStateGlobal = washingMachine .getWashingMachineState ();
52
+ if (machineStateGlobal ==null ) {
53
+ machineStateGlobal = washingMachine .getWashingMachineState ();
54
+ }
51
55
});
52
56
executorService .shutdown ();
53
57
try {
You can’t perform that action at this time.
0 commit comments