KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > thread > ThreadControl


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.excalibur.thread;
18
19 /**
20  * This interface defines the method through which Threads can be controller.
21  *
22  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
23  */

24 public interface ThreadControl
25 {
26     /**
27      * Wait for specified time for thread to complete it's work.
28      *
29      * @param milliSeconds the duration in milliseconds to wait until the thread has finished work
30      * @throws IllegalStateException if isValid() == false
31      * @throws InterruptedException if another thread has interrupted the current thread.
32      * The interrupted status of the current thread is cleared when this exception
33      * is thrown.
34      */

35     void join( long milliSeconds )
36         throws IllegalStateException JavaDoc, InterruptedException JavaDoc;
37
38     /**
39      * Call {@link Thread#interrupt()} on thread being controlled.
40      *
41      * @throws IllegalStateException if isValid() == false
42      * @throws SecurityException if caller does not have permission to call interupt()
43      */

44     void interrupt()
45         throws IllegalStateException JavaDoc, SecurityException JavaDoc;
46
47     /**
48      * Determine if thread has finished execution
49      *
50      * @return true if thread is finished, false otherwise
51      */

52     boolean isFinished();
53
54     /**
55      * Retrieve throwable that caused thread to cease execution.
56      * Only valid when true == isFinished()
57      *
58      * @return the throwable that caused thread to finish execution
59      */

60     Throwable JavaDoc getThrowable();
61 }
62
Popular Tags