code: public void execute() throws ActivityException {
          EventWaitInstance received = registerWaitEvents(false, true);
          if (received!=null) {
              setReturnCodeAndExitStatus(received.getCompletionCode());
              processMessage(getExternalEventInstanceDetails(received.getMessageDocumentId()));
              boolean toFinish = handleCompletionCode();
              if (toFinish && exitStatus==null)
                  exitStatus = WorkStatus.STATUS_COMPLETED;
          }
          else {
              try {
                  // set timeouts
                  int timeout = getTimeoutSeconds();
                  if (timeout > 0) {
                      loginfo("set activity timeout as " + timeout + " seconds");
                      InternalEvent delayMsg = InternalEvent.createActivityDelayMessage(getActivityInstance(), getMasterRequestId());
                      getEngine().sendDelayedInternalEvent(delayMsg, timeout,
                              ScheduledEvent.INTERNAL_EVENT_PREFIX+getActivityInstanceId()+"timeout", false);
                  }
              }
              catch (MdwException e) {
                  throw new ActivityException(0, "Failed to set timeout", e);
              }
          }
      }
docs: Method that executes the logic based on the work