You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/09/28 03:57:56 UTC

cvs commit: jakarta-avalon-excalibur/thread/src/java/org/apache/excalibur/thread Executable.java ThreadPool.java ThreadControl.java

donaldp     2002/09/27 18:57:56

  Added:       thread/src/java/org/apache/excalibur/thread Executable.java
                        ThreadPool.java ThreadControl.java
  Log:
  Move across the old threadpool stuff to new package hierarcchy
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/thread/src/java/org/apache/excalibur/thread/Executable.java
  
  Index: Executable.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.thread;
  
  /**
   * The Executable can be implemented by components that need to perform
   * some work. In many respects it is similar to Runnable except that it
   * also allows an application to throw a non-Runtime Exception.
   *
   * <p>The work done may be short lived (ie a simple task) or it could
   * be a long running.</p>
   *
   * @author <a href="mailto:peter at apache.org">Peter Donald</a>
   */
  public interface Executable
  {
      /**
       * Execute the action associated with this component.
       *
       * @throws Exception if an error occurs
       */
      void execute()
          throws Exception;
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/thread/src/java/org/apache/excalibur/thread/ThreadPool.java
  
  Index: ThreadPool.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.thread;
  
  /**
   * This class is the public frontend for the thread pool code.
   *
   * @author <a href="mailto:peter at apache.org">Peter Donald</a>
   */
  public interface ThreadPool
  {
      /**
       * Run work in separate thread.
       * Return a valid ThreadControl to control work thread.
       *
       * @param work the work to be executed.
       * @return the ThreadControl
       */
      ThreadControl execute( Runnable work );
  
      /**
       * Run work in separate thread.
       * Return a valid ThreadControl to control work thread.
       *
       * @param work the work to be executed.
       * @return the ThreadControl
       */
      ThreadControl execute( Executable work );
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/thread/src/java/org/apache/excalibur/thread/ThreadControl.java
  
  Index: ThreadControl.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.thread;
  
  /**
   * This interface defines the method through which Threads can be controller.
   *
   * @author <a href="mailto:peter at apache.org">Peter Donald</a>
   */
  public interface ThreadControl
      extends org.apache.avalon.excalibur.thread.ThreadControl
  {
      /**
       * Wait for specified time for thread to complete it's work.
       *
       * @param milliSeconds the duration in milliseconds to wait until the thread has finished work
       * @throws IllegalStateException if isValid() == false
       * @throws InterruptedException if another thread has interrupted the current thread.
       *            The interrupted status of the current thread is cleared when this exception
       *            is thrown.
       */
      void join( long milliSeconds )
          throws IllegalStateException, InterruptedException;
  
      /**
       * Call Thread.interupt() on thread being controlled.
       *
       * @throws IllegalStateException if isValid() == false
       * @throws SecurityException if caller does not have permission to call interupt()
       */
      void interupt()
          throws IllegalStateException, SecurityException;
  
      /**
       * Determine if thread has finished execution
       *
       * @return true if thread is finished, false otherwise
       */
      boolean isFinished();
  
      /**
       * Retrieve throwable that caused thread to cease execution.
       * Only valid when true == isFinished()
       *
       * @return the throwable that caused thread to finish execution
       */
      Throwable getThrowable();
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>