Guarded suspension

In concurrent programming, guarded suspension[1] is a software design pattern for managing operations that require both a lock to be acquired and a precondition to be satisfied before the operation can be executed.

Because it is blocking, the guarded suspension pattern is generally only used when the developer knows that a method call will be suspended for a finite and reasonable period of time.

If a method call is suspended for too long, then the overall program will slow down or stop, waiting for the precondition to be satisfied.

If the developer knows that the method call suspension will be indefinite or for an unacceptably long period, then the balking pattern may be preferred.

In Java, the Object class provides the wait() and notify() methods to assist with guarded suspension.