1 4 package demo.jmx; 5 6 import org.springframework.beans.factory.BeanNameAware; 7 8 11 public class Counter 12 implements ICounter, BeanNameAware 13 { 14 private volatile int counter = 0; 15 private String name; 16 17 public int next() 18 { 19 synchronized(this) 20 { 21 return counter++; 22 } 23 } 24 25 public int getCurrent() 26 { 27 return counter; 28 } 29 30 public String getName() 31 { 32 return this.name; 33 } 34 35 public void setBeanName(String name) 36 { 37 this.name = name; 38 } 39 } 40 41 | Popular Tags |