|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectBarrierSec
public class BarrierSec
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].
mutex semaphore is used to ensure that only one Bob
is performing a task.reduce is initialized using the number of Bobs
because each Bob[i] needs to signal that they finished all his
task before termination.
| 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 |
|---|
static final int N_Activities
static int activity
static int remain
static final int ManyBobs
| Constructor Detail |
|---|
public BarrierSec()
| Method Detail |
|---|
public static void main(String[] args)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||