blob: 795ad8a26c24efaa75d19bcbfd44f9d064ffd1a0 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001// NPCTE fix for bugId 4510777, esc 532372, MR October 2001
2// file Task.java created for this bug fix
3/*
4 * Copyright 2002-2003 Sun Microsystems, Inc. All Rights Reserved.
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 *
7 * This code is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation. Sun designates this
10 * particular file as subject to the "Classpath" exception as provided
11 * by Sun in the LICENSE file that accompanied this code.
12 *
13 * This code is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * version 2 for more details (a copy is included in the LICENSE file that
17 * accompanied this code).
18 *
19 * You should have received a copy of the GNU General Public License version
20 * 2 along with this work; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 * CA 95054 USA or visit www.sun.com if you need additional information or
25 * have any questions.
26 */
27package com.sun.jmx.snmp.tasks;
28
29/**
30 * This interface is implemented by objects that can be executed
31 * by a {@link com.sun.jmx.snmp.tasks.TaskServer}.
32 * <p>A <code>Task</code> object implements two methods:
33 * <ul><li><code>public void run(): </code> from
34 * {@link java.lang.Runnable}</li>
35 * <ul>This method is called by the {@link com.sun.jmx.snmp.tasks.TaskServer}
36 * when the task is executed.</ul>
37 * <li><code>public void cancel(): </code></li>
38 * <ul>This method is called by the {@link com.sun.jmx.snmp.tasks.TaskServer}
39 * if the <code>TaskServer</code> is stopped before the
40 * <code>Task</code> is executed.</ul>
41 * </ul>
42 * An implementation of {@link com.sun.jmx.snmp.tasks.TaskServer} shall call
43 * either <code>run()</code> or <code>cancel()</code>.
44 * Whether the task is executed synchronously in the current
45 * thread (when calling <code>TaskServer.submitTask()</code> or in a new
46 * thread dedicated to the task, or in a daemon thread, depends on the
47 * implementation of the <code>TaskServer</code> through which the task
48 * is executed.
49 * <p>The implementation of <code>Task</code> must not make any
50 * assumption on the implementation of the <code>TaskServer</code> through
51 * which it will be executed.
52 * <p><b>This API is a Sun Microsystems internal API and is subject
53 * to change without notice.</b></p>
54 * @see com.sun.jmx.snmp.tasks.TaskServer
55 *
56 * @since 1.5
57 **/
58public interface Task extends Runnable {
59 /**
60 * Cancel the submitted task.
61 * The implementation of this method is Task-implementation dependent.
62 * It could involve some message logging, or even call the run() method.
63 * Note that only one of run() or cancel() will be called - and exactly
64 * one.
65 **/
66 public void cancel();
67}