Class BarrierSec

java.lang.Object
  extended by BarrierSec

public class BarrierSec
extends Object

This class shows how to synchronice a bunch of people who perform many activities. This implementation is very inefficient because only 1 Bob can work at a time. The main requirement is that no one will be performing activity n+1 until everybody finishes activity n. Each person is called Bob[i].

This is an example of Map/Reduce. In the "Map" face, in programa "main()", the syncrhonization semaphores are set up and the Bob processes are created. The "Reduce" is executed after all the Bob processes are done.


Field Summary
(package private) static int activity
          Current activity to be performed by every Bob.
(package private) static int ManyBobs
          A bunch of Bobs perform the activities.
(package private) static int N_Activities
          This many task will be performed.
(package private) static int remain
          Number of Bobs that didnīt finish current activity yet.
 
Constructor Summary
BarrierSec()
           
 
Method Summary
static void main(String[] args)
          Main program.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

N_Activities

static final int N_Activities
This many task will be performed.

See Also:
Constant Field Values

activity

static int activity
Current activity to be performed by every Bob.


remain

static int remain
Number of Bobs that didnīt finish current activity yet.


ManyBobs

static final int ManyBobs
A bunch of Bobs perform the activities.

See Also:
Constant Field Values
Constructor Detail

BarrierSec

public BarrierSec()
Method Detail

main

public static void main(String[] args)
Main program.