while (1) { if (shared.die) { exit; } elsif (shared.do_this) { do_this; } elsif (shared.do_that) { do_that; } ... else { wait_for_event(); } }