9 public add(long value){
15 public synchronized long getCounter() {
20 public class CounterThread extends Thread{
23 protected Counter counter;
25 public CounterThread(String name, Counter counter){
27 this.counter = counter;
31 for(int i=0; i<10; i++){
32 System.printString(this.name);
34 System.printString(" " + counter.getCounter() + "\n");
39 public class SynchonizedTest {
40 public SynchonizedTest() {
43 public static void main(String[] args){
44 Counter counter = new Counter();
45 Thread threadA = new CounterThread("A\n",counter);
46 Thread threadB = new CounterThread("B\n",counter);
52 /*public static void main(String[] args){
53 Counter counterA = new Counter();
54 Counter counterB = new Counter();
55 Thread threadA = new CounterThread("A\n",counterA);
56 Thread threadB = new CounterThread("B\n",counterB);