RACE CONDITION IN JAVA

       

Race Condition in Java is a type of issue which will come to our program due to parallel execution of the Programme by multiple threads at same time..
Risk of race condition in Java is high because Java supports multi-threading..
e.g if(!hastable.contains(key)){ hastable.put(key,value); } Insert the value if value is not there..
Lets take thread T1 checks for the condtions and goes inside and doing the execution or blocked..
Now thread T2 which also check the condtion and goes if inside if T1 still has not inserted the value.So in this kind of sitution either T1 value will overrwrite T2 value or vice-versa..