9 public synchronized void add(long value){
11 System.printString(" " + this.count + "\n");
14 public synchronized long getCounter() {
19 public class CounterThread extends Thread{
22 protected Counter counter;
24 public CounterThread(String name, Counter counter){
26 this.counter = counter;
30 for(int i=0; i<10; i++){
31 System.printString(this.name);
37 public class SynchonizedTest {
38 public SynchonizedTest() {
41 public static void main(String[] args){
42 Counter counter = new Counter();
43 Thread threadA = new CounterThread("A\n",counter);
44 Thread threadB = new CounterThread("B\n",counter);