<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def run(self):
 """ Starts the thread """


        task = None
        monitor_task = MonitorTask(
            notification_endpoint=self._handle_message)

        while True:
            if self._terminate:
                self._logger.info("scsgate.Reactor exiting")
                self._connection.close()
                break
            try:
                task = self._request_queue.get_nowait()
                self._logger.debug("scsgate.Reactor: got task {}".format(task))
            except queue.Empty:
                task = monitor_task

            try:
                task.execute(connection=self._connection)
            except ExecutionError as err:
                self._logger.error(err)