Recently I wrote something like this:
public void doSomething(boolean b1, boolean b2){
while(true){
if(b1){
doThis();
}
if(b2){
doThat();
}
}
}
But I really don't like this solution, because in every iteration you will have to check the 2 booleans. So as possible solution I could imagine to write 4 while loops with the ifs before each loop, but for obvious reasons this sucks in maintainability. Do you have any suggestions to make this piece of code nice and effective?