Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is race condition in java? How will you find and solve race condition?

user-image
Question added by Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
Date Posted: 2015/02/12
mostafa mohamed korkar
by mostafa mohamed korkar , java developer , Etisalat misr

A race condition occurs when two or more threads can access shared data and they try to change it at the same time.

To Solve : 

In order to prevent race conditions from occurring, you would typically put a lock around the shared data to ensure only one thread can access the data at a time. where you will use the keyword Synchronized