Skip navigation links
org.apache.commons.io

Class ThreadMonitor

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      private java.lang.Thread thread 
      private long timeout 
    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
      private ThreadMonitor(java.lang.Thread thread, long timeout)
      Construct and new monitor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void run()
      Sleep until the specified timout amount and then interrupt the thread being monitored.
      static java.lang.Thread start(long timeout)
      Start monitoring the current thread.
      static java.lang.Thread start(java.lang.Thread thread, long timeout)
      Start monitoring the specified thread.
      static void stop(java.lang.Thread thread)
      Stop monitoring the specified thread.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • thread

        private final java.lang.Thread thread
      • timeout

        private final long timeout
    • Constructor Detail

      • ThreadMonitor

        private ThreadMonitor(java.lang.Thread thread,
                              long timeout)
        Construct and new monitor.
        Parameters:
        thread - The thread to monitor
        timeout - The timout amount in milliseconds
    • Method Detail

      • start

        public static java.lang.Thread start(long timeout)
        Start monitoring the current thread.
        Parameters:
        timeout - The timout amount in milliseconds or no timeout if the value is zero or less
        Returns:
        The monitor thread or null if the timout amount is not greater than zero
      • start

        public static java.lang.Thread start(java.lang.Thread thread,
                                             long timeout)
        Start monitoring the specified thread.
        Parameters:
        thread - The thread The thread to monitor
        timeout - The timout amount in milliseconds or no timeout if the value is zero or less
        Returns:
        The monitor thread or null if the timout amount is not greater than zero
      • stop

        public static void stop(java.lang.Thread thread)
        Stop monitoring the specified thread.
        Parameters:
        thread - The monitor thread, may be null
      • run

        public void run()
        Sleep until the specified timout amount and then interrupt the thread being monitored.
        Specified by:
        run in interface java.lang.Runnable
        See Also:
        Runnable.run()

Copyright (c) 2002-2016 Apache Software Foundation