aboutsummaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.lang/PR18699.java
blob: 6f81e10d9f358b3aca51241f29925675d60ccde7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Test for thread-local allocation problems.

import java.util.HashMap;
import java.util.Observable;
import java.util.Observer;

class PR18699 extends Observable implements Runnable, Observer {

  public static void main(String[] args) throws InterruptedException {
    PR18699 PR18699_1 = new PR18699();
    PR18699 PR18699_2 = new PR18699();
    PR18699_1.addObserver(PR18699_2);
    PR18699_2.addObserver(PR18699_1);
    new Thread(PR18699_1).start();
    new Thread(PR18699_2).start();
  }

  public void run() {
    int c = 0;
    String s = "";
    while (++c < 50) {
      this.setChanged();
      s = "";
      for (int i = 0; i < 200; i++)
        s += String.valueOf(i);
      this.notifyObservers(s);
    }
  }

  HashMap map = new HashMap();
  
  public void update(Observable o, Object obj) 
  {
    map.put(o, obj);
  }
}