Actually I think it is possible.
This is actually based on the Java documentation.
public class MyCyclicBarrier {
private CyclicBarrier barrier;
private boolean done = false;
class Task implements Runnable {
public void run() {
while (!done) {
try {
long l = barrier.await();
System.out.println( "Thread indexed [" + l + "] has
run");
} catch (InterruptedException ex) {
return;
} catch (BrokenBarrierException ex) {
return;
}
}
}
}
public void compute() {
barrier = new CyclicBarrier( 10,
new Runnable() {
public void run() {
done = true;
System.out.println( "Barrier
action ->>" + Boolean.toString( done ));
}
});
for (int i = 0; i < 10; ++i){
new Thread(new Task()).start();
}
while (!done) {
System.out.println( "Waiting till done");
}
}
public static void main( String[] argv ){
new MyCyclicBarrier().compute();
}
I think there is an base example found here.
http://www.michaelharrison.ws/weblog/?p=239
Shouldn't I be directly translating java.util.concurrent to Clojure's
concurrency model because they are fundamentally different ?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en