Concurrent Programming with Java
Lab Manual, Version 1.0, F. Astha Ekadiyanto,
2002.
Lab 4: Introduction to Threads
By now, your VisualMobileSystem Applet should work similar as planned.
If you have been so successful so far, let us make a little difficult problem for you.Try to Click and/or Drag your mouse over the shapes for a couple of time and see what happened.
As usual, if it does not work, try to download the JAR File and run from command line (java -jar lab4C.jar
)
The responsive MobileStation ("Yes,....where should I go?")
Now, rather than creating many MobileStation and set their mobility Path, we will just play the only existing one. We can set its mobility Path and alter it as much as we want (while the Mobile Station is actually moving). Try to modify your code so that this could happened. Think of the solution as if you will later play with more than one MobileStation, and you can choose and change each MobileStation's mobility Path and all the MobileStations will response immediately.
Hint: There are many ways to solve the problem. Among them are:
- Accessing the MobileTask Object and modify its target when mouse released. But be careful since the so called "Path Finder" algorithm in the MobileTask may perform in an unexpected way (a jump when target changed).
- Creating a new MobileTask with the new target when mouse released. But be careful since your previous task may still be working with the same MobileStation (finally your tasks may competing each other to control the MobileStation to their own destination....thinking like there are two people or even more trying to gain your love..).
This Challenge may consume a lot of your time. If you have successfully solved the Simple Challenge, this may be your true Challenge.
Try to do it only in your spare time.The MobileStation "Game"
Description
- In the Applet below, you will be able to create many mobile stations, and place them in the topology
- You can select a group of Mobile Stations exist in the topology and set their movement direction all at one.
- You can also select another group of Mobile Stations and set another movement direction.
- Finally, you can select some Mobile Stations and remove them from the topology.
- Try it!! And if you have figured it out, make a code of it!
- As usual, if it does not work, try to download the JAR File and run from command line (
java -jar lab4D.jar
)