package myintergertest; /** * * @author Engineering */ public class Main { /** * @param args the command line arguments */ public static void
See AtomicInteger: http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/AtomicInteger.html
You can do it thread-safe using this java.util.concurrent class.