• Rahul Prabhune

Balking Design Pattern

In Balking Design Pattern if an object’s method is invoked when it is in an inappropriate state, then the method will return without doing anything. Objects that use this pattern are generally only in a state that is prone to balking temporarily but for an unknown amount of time In this example implementation Washing Machine is an object that has two states in which it can be: ENABLED and WASHING. If the machine is ENABLED the state is changed into WASHING that any other thread can't invoke this action on this and then do the job. On the other hand if it have been already washing and any other thread execute wash() it can't do that once again and returns doing nothing.