Thursday, 15 December 2011

Creating Polite Long-Running Methods

The final step in providing a clean shutdown is to make any long-running methods behave politely. Methods that might run for a long time should check the value of the field that notifies them of shutdowns and should interrupt their work, if necessary.
public void doPost(...) {
   for(i = 0; ((i < lotsOfStuffToDo) && 
      !isShuttingDown()); i++) {
      try {
      } catch (InterruptedException e) {
See Notifying Methods to Shut Down

No comments:

Post a Comment