Friendly Threads


Since Threads share Process resources the application code needs to be careful to coordinate access to those resources. However, there are many situations where Threads, thought very useful, interact minimally . Below are some examples:

The Tower of Hanoi

Hanoi

The idea is to move the disks from one peg to another, one at a time but always putting a smaller disk on top of a bigger one. The TIMER is a separate Thread that just measures the time it takes for the user to finish the task. It starts went the first disk is moved and ends when the last is put in place.
 
SOLUTION is also a separate Thread that solves the puzzle without user input.


A .jar/WebPage Browser:

  1. startURL.java
  2. MyBrowser.java
  3. JarRunner.java
  4. Hanoi.java
  5. Hanoi -background
  6. startURL.jar

My Browser

My Browser

My Browser

Each time a URL is entered in My Browser and an appropriate button is clicked, the URL Content appears in a new Window Thread. These Windows can be closed independently of My Browser but closing My Browser does kill the other Threads. This is essentially the only other interaction besides starting the Threads.