That example should, of course, read:
class Tearer extends Thread {
static byte[] counts = new byte[1000]; // 1000 is arbitrary
//^^^^^^
final int id;
Tearer(int i) { id = i; }
public void run() {
int iters = 0;
while (counts[id]++ < 100) ++iters; // 100 is semi-arbiratry
assert iters == 100; // Uses upcoming assert syntax
}
public static void main(String[] args) {
for (int i = 0; i < 1000; ++i)
new Tearer(i).start();
}
}
-Doug
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:25 EDT