"Race condition" Threads are running at the same time and you cannot predict with certainty which the exact order in which commands fire. How can we deal with race conditions. One good way is to solve our problem in such a way that race conditions don't matter. No matter what order the commands fire in, the answer is the same in any event. 2x2 2x3 1 2 1 2 3 3 4 4 5 6 What is the size of the resulting matrix from the multiplication? 2x3 9 12 15 19 26 33 Make a thread for EACH entry in the answer matrix. (In this case, 6 threads.) each thread computes its answer from its designated row and column from the input matrices. They all run in parallel, and race conditions do not matter. There are several different techniques to prevent race conditions by ensuring that threads do not interfere in those situations in which race conditions might arise. We will be looking at three common paradigms. 1. Locks (very easy but very crude). 2. Semaphores (more powerful...but be careful0 3. Monitors (which tie in well to an object-oriented platform) Locks: only one thread can hold a lock. If a thread tries to lock a lock that's already been locked, it freezes until such time as the lock becomes unlocked.