001    package javax.realtime;
002    
003    /** <code>Interruptible</code> is an interface implemented by classes
004     *  that will be used as arguments on the <code>doInterruptible()</code>
005     *  of <code>AsynchronouslyInterruptedException</code> and its
006     *  subclasses. <code>doInterruptible()</code> invokes the implementation
007     *  of the method in this interface. Thus the system can ensure
008     *  correctness before invoking <code>run()</code> and correctly
009     *  cleaned up after <code>run()</code> returns.
010     */
011    public interface Interruptible {
012    
013        /** This method is called by the system if the <code>run()</code> method
014         *  is excepted. Using this the program logic can determine if the
015         *  <code>run()</code> method completed normally or had its control
016         *  asynchronously transferred to its caller.
017         *
018         *  @param exception Used to invoke methods on
019         *                   <code>AsynchronouslyInterruptedException</code> from
020         *                   within the <code>interruptAction()</code> method.
021         */
022        public void interruptAction(AsynchronouslyInterruptedException exception);
023    
024        /** The main piece of code that is executed when an implementation is
025         *  given to <code>doInterruptible()</code>. When you create a class
026         *  that implements this interface (usually through an anonymous inner
027         *  class) you must remember to include the <code>throws</code> clause
028         *  to make the method interruptible. If the throws clause is omitted
029         *  the <code>run()</code> method will not be interruptible.
030         *
031         *  @param exception Used to invoke methods on
032         *                   <code>AsynchronouslyInterruptedException</code> from
033         *                   within the <code>interruptAction()</code> method.
034         */
035        public void run(AsynchronouslyInterruptedException exception)
036            throws AsynchronouslyInterruptedException;
037    }