Add listeners to Callable (see www.forward.com.au for an article on how to use this package.)
The {@link au.com.forward.futureTalker.FutureTalker} class allows you to add {@link au.com.forward.futureTalker.IFutureListener}s to your tasks. These listeners will be called when the task completes or terminates with an error or is cancelled.
{@link au.com.forward.futureTalker.FutureTalker} also contains two static utility methods,
{@link au.com.forward.futureTalker.FutureTalker#ifInterruptedStop ifInterruptedStop} which throws an InterruptedException {@link java.lang.InterruptedException} if the current thread has its interrupt flag set.
{@link au.com.forward.futureTalker.FutureTalker#shutdownNow shutdownNow} which shuts down a ThreadPoolExecutor and then rejects {@link au.com.forward.futureTalker.FutureTalker}s and cancels Futures which were waiting to be executed.
{@link au.com.forward.futureTalker.TaskUtilities} contains a number of methods which return interruptable InputStreams, OutputStreams, Readers and Writers for FileInputStreams, FileOutputStreams, RandomAccessFiles and System.in, System.out and System.err
Similar coding can be used for Sockets and Pipes. See InterruptibleChannel for the classes availale.
FutureTalker package Copyright (c) 2004 Forward Computing and Control Pty. Ltd. NSW. Australia, www.forward.com.au All rights reserved. Redistribution of the source and/or compiled .class of this package, with or without modification, is permitted subject to the limitation of libability below. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.