Class BarrierMap
java.lang.Object
BarrierMap
public class BarrierMap
- extends Object
This class shows how to synchronice a bunch of people who perform many activities.
The main requirement is that no one will be performing activity n+1
until
every body finised activity n
. Each person is called Bob[i]
.
- In the main program, a loop is used to perform each activity.
- Semaphore
BarrierMap.reduce
is created anew on each cicle to initialize
it with one permito for each Bobs. Thi semaphore is used to know when all the
Bobs are done.
This is an example of a centralized authority that lets many processes rund
concurrently without knowing that they are executing in parallel. In a distributed
systems this central authority does not exist.
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.
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 |
BarrierMap
public BarrierMap()
main
public static void main(String[] args)
- Main program.