أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
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