PageRenderTime 30ms CodeModel.GetById 22ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/razpub/src/com/razie/pubstage/life/Barrier.java

http://razpub.googlecode.com/
Java | 35 lines | 20 code | 4 blank | 11 comment | 3 complexity | b34690c8462d7a48b1ee648143a935da MD5 | raw file
 1/**
 2 * Razvan's public code. Copyright 2008 based on Apache license (share alike) see LICENSE.txt for
 3 * details.
 4 */
 5package com.razie.pubstage.life;
 6
 7import java.util.ArrayList;
 8import java.util.List;
 9
10/**
11 * simple MT barrier waiting for a few threads to finish
12 * 
13 * TODO 3-3 implement
14 * 
15 * @author razvanc99
16 */
17public class Barrier {
18    List<Worker> workers;
19
20    public Barrier(Worker... workers) {
21        this.workers = new ArrayList<Worker>();
22        for (Worker w : workers)
23            this.workers.add(w);
24    }
25
26    public boolean check() {
27        boolean done = true;
28        for (Worker w : workers)
29            if (!w.isDone()) {
30                done = false;
31                break;
32            }
33        return done;
34    }
35}