synchronized int getIndex() { return (index++); } static int MAX_NUM_THREADS = 10; public static void main(String[] args) throws InterruptedException { int size = 1000000; int[] a = new int[size]; for (int i=0; ia[i] = i; } MapTest m = new MapTest(a); for (int i = 0; i < MAX_NUM_THREADS; i++) { Thread t = new Thread(m); t.start(); } } }