Disclaimer

Processes, threads, and Java

CSA-Prep, Fall 2004

Some terms

Race condition example

Consider the following producer/consumer problem.

Details of a race condition in producer/consumer example

producer                    consumer
                               +>
                               |  repeat forever
                               |     ...
                               |     // ASSUME count=0 NOW
                               |     if (count == 0)
			      <+
   produce an item	       |
   if (count == MAX)	       |
      sleep()  		       |
   insert an item	       |
   count = count + 1	       |
   if (count == 1)	       |
      wakeup(consumer)	       |
   produce an item	       |
   ...             	       |
                               +>
                               |        sleep()  // BLOCK!
			      <+
   ...             	       |
   // ASSUME count=MAX NOW     |
   produce an item	       |
   if (count == MAX)	       |
      sleep() // BLOCK!	       |

Threads in Java

IPC in Java





rab@stolaf.edu, October 27, 2004