def stop &block
      if block_given? then
        @stopped = true
        @suspended = false
        # Wait till something is put on the dead queue...
        # This stops us from acquiring the mutex until after @thread
        # has processed @stopped set to true.
        sig = @dead.deq
        # The cron thread should be dead now, or wrapping up (with the
        # acquired mutex)... 
        @mutex.synchronize {
          while @thread.alive?
            sleep 0.2
          end
          block.call(self)
        }
      end
    end
def stop &block
      if block_given? then
        @stopped = true
        @suspended = false
        # Wait till something is put on the dead queue...
        # This stops us from acquiring the mutex until after @thread
        # has processed @stopped set to true.
        sig = @dead.deq
        # The cron thread should be dead now, or wrapping up (with the
        # acquired mutex)... 
        @mutex.synchronize {
          while @thread.alive?
            sleep 0.2
          end
          block.call(self)
        }
      end
    end
Gracefully stop the thread.

 If block is given, it will be called once the thread has
 stopped.