while looking at the code for the sense reversing barrier, I could not figure out why the code (see below) needs a thread-local variable and not simply have mySense get the negation of the main "sense" variable. I cannot see the need for each thread to keep state between invocations. Did I miss something?
Thank you.
[]'s
Andrey
---------------
public class Barrier {
AtomicInteger count;
int size;
boolean sense = false;
threadSense = new ThreadLocal<boolean>…
public void await {
boolean mySense = threadSense.get();
if (count.getAndDecrement()==1) {
count.set(size); sense = !mySense
} else {
while (sense != mySense) {}
}
threadSense.set(!mySense)}}}