Multiple exit loop handling in ivopts. Regression tested on x86-64/linux
[official-gcc.git] / libjava / testsuite / libjava.lang / SyncTest.java
blob85573f8a4b958f196b0942b546cee02fc5aed430
1 // Test atomic increment via synchronized blocks.
2 public class SyncTest implements Runnable {
3 static int counter;
5 public void run() {
6 // We cache the .class value; otherwise this code is
7 // slow enough that it will time out in some situations.
8 Object lock = SyncTest.class;
9 for (int n = 0; n < 1000000; n++)
10 synchronized (lock) {
11 counter++;
15 public static void main(String[] args) {
16 SyncTest test = new SyncTest();
17 Thread[] thr = new Thread[4];
19 for (int n = 0; n < thr.length; n++) {
20 thr[n] = new Thread(test);
21 thr[n].start();
24 for (int n = 0; n < thr.length; n++) {
25 try {
26 thr[n].join();
27 } catch (InterruptedException ex) {
31 System.out.println(counter == 1000000 * thr.length ?
32 "ok" : "fail: " + counter);