Saturday 13 May 2017

23. Critical section and Race conditions

1. What is race condition?
  1. If multiple threads are operating simultaneously on same java object then there may be a chance of data consistency problem, this is called race condition.
  2. We can overcome this problem by using synchronized keyword.
2. What is critical section?
  1. A critical section is a section of code that is executed by multiple threads and where the sequence of execution for the threads makes a difference in the result of the concurrent execution of the critical section.
  2. The section of code gives a problem called race condition.
3. Example of race condition?
4. How to avoid race condition?

  1. We can overcome this problem by using synchronized keyword.

No comments:

Post a Comment

3. Java Program to create Binary Tree