CIS 636 Threads examples

Curricula
syllabus |
announcements |
assignments | discussion

Archives
student work |
review notes

Resources
research materials |
tutorials | |

Contacts
home to: course | instructor |
department | La Salle home

E-Mail: redmond@lasalle.edu  


Fall 2002

Some of these use an updated version of RedmondMsgIn.java

=================================================================

Very basic, almost silly examples.

SillyUseThread.java - OR view Text version of SillyUseThread.java
SillyImpRunnableThread.java - OR view Text version of SillyImpRunnableThread.java
TestUnrelatedThreads.java - OR view Text version of TestUnrelatedThreads.java

=================================================================

Test for prime examples. First doesn't use shared data and is careful. It doesn't need to be synchronized. It is what I almost finished on 3/17 - cleaned up. Second is unsynchronized with shared data - gets count of factors wrong. Third is synchronized.

TestPrimesCarefulImplRunThread.java - OR view Text version of TestPrimesCarefulImplRunThread.java along with the corresponding main PrimeMain.java - OR view Text version of PrimeMain.java

TestPrimesImplRunThread.java - OR view Text version of TestPrimesImplRunThread.java
TestPrimesSynchObjThread.java - OR view Text version of TestPrimesSynchObjThread.java
=================================================================

Pressure gauge example - uses two files - first two are unsynchronized - device blows up because pressure gets out of hand. Second is safer - synchronized.

Pressure.java - OR view Text version of Pressure.java
TestPressure.java - OR view Text version of TestPressure.java

SafePressure.java - OR view Text version of SafePressure.java
TestSafePressure.java - OR view Text version of TestSafePressure.java

=================================================================

Example for communicating, synchronized code. Dr Longo's producer and consumer example. This may seem abstract, but communicating threads tend to either produce something that other thread needs or consume what is produced. In this case, code is simple since what is produced and consumed are merely integers.

Consumer.java - OR view Text version of Consumer.java
PCmain.java - OR view Text version of PCmain.java
Producer.java - OR view Text version of Producer.java
Q.java - OR view Text version of Q.java

=================================================================

A banking example using threads. Still need some willful suspension of disbelief, but better than on earlier assignment. This example actually has each customer handled by a different thread - and setup and shut down handled by a different thread (main in this case)

AccountSynch.java - OR view Text version of AccountSynch.java
NegativeAmount.java - OR view Text version of NegativeAmount.java
TestBankSynchThread.java - OR view Text version of TestBankSynchThread.java

=================================================================

Class to be used with thread assignment:

ChessPiece.java - OR view Text version of ChessPiece.java

=================================================================

Example for communicating, synchronized code using PipedInputStreams. Dr Longo's piped version of producer and consumer example.

Consumer.java - OR view Text version of Consumer.java
Producer.java - OR view Text version of Producer.java
PCpipeMain.java - OR view Text version of PCpipeMain.java

=================================================================