oval


Centre International de Mathİmatiques Pures et Appliquİes
International Center for Pure and Applied Mathematics


A CIMPA-UNSA-INRIA-UNESCO-VIETNAM SCHOOL ON


Objects and Network
Threads Exercises


Emmanuel Chailloux
Emmanuel.Chailloux@lip6.fr
http://www-spi.lip6.fr/~emmanuel

Shared memory

All process interact on the same memory :
figure=shared.eps,height=0.4

Ş implicit communication and explicit synchronization!!!

Relations between Threads

  1. Unrelated Threads
  2. Related but Unsynchronized Threads
  3. Mutually Exclusive Threads
  4. Communicating Mutually-Exclusive Threads
Threads Exercises

Exercises : Threads

A simulation for cellulars automaton

The following source program is a text version for the Game of Life (a simulation for cellulars automats).

GameOfLife.java

To follow the different tasks :

  1. To extend the inheritence tree to build an applet from this application. You don't have to modify the original source. You can display the old and the new generations.

  2. To write an HTML file which starts two applets of ``Game of Life''. To test it with appletviewer and a browser.

  3. To modify the code to run four (independent) threads on the same world (you slice the world in four parts). Each thread can display its cells with a different color.

  4. To modify this program with overlap between threads. You need to synchronize threads.

Some Sources



A Producer-Consumer

It's a classical example.

Some Sources



A World of robots

In a special world, represented by a plane, somes robots move. The world contains cells where robots can stay or move. There are different kinds of robots. Each robot will be represented by a thread.

  1. To define a World abstract class.
  2. To define a concrete sub-class for a plane world.
  3. To define an abstract class for the robots.
  4. To define a concrete class for an ``hazardeous''robot. It'll decide by random what will its next position.
  5. To integrate these different classes to build a text application, where robot movements will be displayed.
  6. To build an applet to have a graphical display. A robot will be represented by a colored rectangle.
If you have time, to add others kinds of robots :
This document was translated from LATEX by HEVEA.