20-CS-4003-001 Organization of Programming Languages Fall 2018

Lambda calculus, Type theory, Formal semantics, Program analysis

All lectures
Introduction, Producer-Consumer

Instructions for all applets:
All applets contain a button labeled 'Jar File'. Click it to download a jar file (executable). Some applets also have a choice of modes. All applets come in pairs. The difference between two applets of a pair is that the control portion of the code in the upper applet is Threaded (class Test?Doer) and this portion of code is not threaded in the lower applet. Sometimes this affects whether output can be seen.

Classes common to all files below:

  -   notify, notifyAll: A simple test of notify, notifyAll, wait, synchronize. The Monitor M1 allows W1 objects to wait (via method 'a') until awakened by an N1 object (via method 'b'). The user may choose to wake up threads using notify or notifyAll.
  -   notify, notifyAll: This does the same as the above except now there are two M1 monitors and two W1 threads wait in one monitor and another W1 thread waits in the other monitor. A single N1 thread invokes the b method of just one of the monitors.
  -   notify, notifyAll: Similar to the applet above except the main thread of Test3Doer in the 1st case and Test3aFrame in the case of the 2nd applet yields right after starting all the W2 threads.
  -   Cause N3 objects to wait for all W3 objects to finish. The W3 objects are awakened one at a time. A hashtable stores all invoking W3 threads. When each finishes it is removed from the hashtable and wakes up the next thread. When the hashtable is empty the N3 threads are released.
  -   sleep has the same effect as yield. Same as two applets up except that sleep is used to suspend the main thread instead of yield.
  -   producer-consumer. A Producer object puts tokens into a "stream" that is managed by monitor Monitor and a Consumer object takes them out of the stream. No new tokens enter the stream unless all tokens have been pulled out. File Test6c.java is an application that details the execution of put and get.
  -   producer-consumer. This is a refinement on the above. The monitor becomes an abstract Stream class. A Producer subclasses this class.
  -   interrupt. A test of interrupt to wake up a thread.
  -   Threads can be tricky. Example showing how tricky Threads can be. Printing is directed to standard out as well as a JTextArea but in the 2nd applet (Test9a.java) nothing appears in the JTextArea. In the 1st applet (Test9b.java) printing to the JTextArea works great. The difference is the control portion of the code is Threaded in this applet (Test9Doer) but not in the sister applet.