code: @Override
      public void run() {
  	int received;
  
  	// noinspection InfiniteLoopStatement
  	while (true) {
  	    // System.out.println("In PollThread loop (sleep=" + sleep +
  	    // ")....");
  	    try {
  		if (sleep != 0) {
  		    received = get_command(sleep);
  		} else {
  		    received = POLL_TIME_OUT;
  		}
  
  		long ctm = System.currentTimeMillis();
  		now.tv_sec = (int) (ctm / 1000);
  		now.tv_usec = (int) (ctm - 1000 * now.tv_sec) * 1000;
  		now.tv_sec = now.tv_sec - Tango_DELTA_T;
  
  		switch (received) {
  		case POLL_COMMAND:
  		    execute_cmd();
  		    break;
  
  		case POLL_TIME_OUT:
  		    one_more_poll();
  		    break;
  
  		case POLL_TRIGGER:
  		    one_more_trigg();
  		    break;
  		}
  
  		ctm = System.currentTimeMillis();
  		after.tv_sec = (int) (ctm / 1000);
  		after.tv_usec = (int) (ctm - 1000 * after.tv_sec) * 1000;
  		after.tv_sec = after.tv_sec - Tango_DELTA_T;
  
  		compute_sleep_time();
  	    } catch (final DevFailed e) {
  		Util.out2.println("OUPS !! A thread fatal exception !!!!!!!!");
  		Except.print_exception(e);
  		Util.out2.println("Trying to re-enter the main loop");
  	    }
  	}
      }
docs: ===============================================================