I assume you have code that looks something like this:
private Monkey GetScaryMonkey(int numberOfHeads){ Monkey ape = null; lock(this) { ape = new Monkey(); ape.AddHeads(numberOfHeads); } return ape; }
To make this condition, you could not just do this:
private Monkey GetScaryMonkey(int numberOfHeads){ if ( numberOfHeads > 1 ) { lock(this) { return CreateNewMonkey( numberOfHeads ); } } return CreateNewMonkey( numberOfHeads ); }
Should work, no?
noocyte
source share