1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
7 /** Provides a generic interface for an object that can be both called
8 * with a given argument and paused. */
9 public interface Pausable extends Callable {
10 /** Executes or unpauses the task. */
11 public Object run(Object o) throws Exception, AlreadyRunningException;
13 /** Pauses the running task at its convienience. */
14 public void pause() throws NotPausableException;
16 public static class NotPausableException extends IllegalStateException {
17 public NotPausableException() {}
18 public NotPausableException(String msg) { super(msg); }
20 public static class AlreadyRunningException extends IllegalStateException {
21 public AlreadyRunningException() {}
22 public AlreadyRunningException(String msg) { super(msg); }