summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing2210.java
blob: e52cfa17eed7fc53d84b99d8520e006d95e00d65 (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
/* Listing2210.java */

public class Listing2210
extends Thread
{
  static int cnt = 0;

  public static void main(String[] args)
  {
    Thread t1 = new Listing2210();
    Thread t2 = new Listing2210();
    t1.start();
    t2.start();
  }

  public void run()
  {
    while (true) {
      synchronized (getClass()) {
        System.out.println(cnt++);
      }
    }
  }
}