Can someone please explain simply what thread contention is?
I have googled it, but cannot seem to find a simple explanation.
Can someone please explain simply what thread contention is?
I have googled it, but cannot seem to find a simple explanation.
Essentially thread contention is a condition where one thread is waiting for a lock/object that is currently being held by another thread. Therefore, this waiting thread cannot use that object until the other thread has unlocked that particular object.
From here:
A contention occurs when a thread is waiting for a resource that is not readily available; it slows the execution of your code, but can clear up over time.
A deadlock occurs when a thread is waiting for a resource that a second thread has locked, and the second thread is waiting for a resource that the first thread has locked. More than two threads can be involved in a deadlock. A deadlock never resolves itself. It often causes the whole application, or the part that is experiencing the deadlock, to halt.
You have 2 threads. Thread A and Thread B, you also have object C.
A is currently accessing object C, and has placed a lock on that object. B needs to access object C, but cannot do so until A releases the lock on object C.
Another word might be concurrency. It is simply the idea of two or more threads trying to use the same resource.