Is this a singleton class? If not, then this is a problem, because many parallel instances can change the value of icounter and, in addition, they will block it forever, because no thread can notify about their instance.
In any case, you must move the synchronization inside the function and block the iCount, not the instance, also make it unstable.
public void myFunct(){ synchronized(iCount) { while(iCount >= 3) { try { wait(); } catch (InterruptedException e) { e.printStackTrace(); } } iCount++; }
source share