| 1. |
Download
this
program which spawns threads of many different priorities. Observe how
the high priority threads are given preference over the lower priority
threads. |
| 2. |
Download Main.java,
Producer.java, Consumer.java and
MyData.java.
Compile all the code and run Main. Notice how the threads are not
properly synchronised. |
| 3. |
Download the new version of MyData.java which uses busy loops. Rewrite
Main so that more than one consumer is running. Observe the
difficulties this presents. |
| 4. |
Download the new version of
MyData.java
which uses Java object monitors and busy loops. Does this help address
the problems observed in Task 3? |
| 5. |
Download the new version of
MyData.java
which uses Java object monitors on code segments rather than whole
methods. This will help avoid any deadlock situations. |
| 6. |
Download the new version of
MyData.java
which uses Java object monitors with wait()
and notify() methods to avoid the requirement for busy loops. |
| 7. |
Try out the
code from Task 7 with many producers and many consumers. Observe how it
maintains its thread safety. |
| 8. |
Implement a
multithreaded program with the following characteristics:
-
Three threads start executing. Adds up all the numbers from 1 to some
large number.
- When all three threads finish, they each print out
their totals.
See partial code here. |