KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > util > threadpool > Task


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.util.threadpool;
23
24 /**
25  * A task for a thread pool.
26  *
27  * @author <a HREF="mailto:adrian@jboss.org">Adrian Brock</a>
28  * @version $Revision: 1958 $
29  */

30 public interface Task
31 {
32    // Constants -----------------------------------------------------
33

34    /** Don't wait for task */
35    static final int WAIT_NONE = 0;
36
37    /** Synchronized start, wait for task to start */
38    static final int WAIT_FOR_START = 1;
39
40    /** Synchronized task, wait for task to complete */
41    static final int WAIT_FOR_COMPLETE = 2;
42
43    // Public --------------------------------------------------------
44

45    /**
46     * Get the type of wait
47     *
48     * @return the wait type
49     */

50    int getWaitType();
51
52    /**
53     * The priority of the task
54     *
55     * @return the task priority
56     */

57    int getPriority();
58
59    /**
60     * The time before the task must be accepted
61     *
62     * @return the start timeout
63     */

64    long getStartTimeout();
65
66    /**
67     * The time before the task must be completed
68     *
69     * @return the completion timeout
70     */

71    long getCompletionTimeout();
72
73    /**
74     * Execute the task
75     */

76    void execute();
77
78    /**
79     * Invoked by the threadpool when it wants to stop the task
80     */

81    void stop();
82
83    /**
84     * The task has been accepted
85     *
86     * @param time the time taken to accept the task
87     */

88    void accepted(long time);
89
90    /**
91     * The task has been rejected
92     *
93     * @param time the time taken to reject the task
94     * @param throwable any error associated with the rejection
95     */

96    void rejected(long time, Throwable JavaDoc t);
97
98    /**
99     * The task has been started
100     *
101     * @param time the time taken to start the task
102     */

103    void started(long time);
104
105    /**
106     * The task has been completed
107     *
108     * @param time the time taken to reject the task
109     * @param throwable any error associated with the completion
110     */

111    void completed(long time, Throwable JavaDoc t);
112
113    // Inner classes -------------------------------------------------
114
}
115
Popular Tags