1 // NPCTE fix for bugId 4510777, esc 532372, MR October 2001 2 // file Task.java created for this bug fix 3 /* 4 * Copyright (c) 2002, 2003, Oracle and/or its affiliates. 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. Oracle designates this 10 * particular file as subject to the "Classpath" exception as provided 11 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 24 * or visit www.oracle.com if you need additional information or have any 25 * questions. 26 */ 27 package 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 **/ 58 public 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 **/ cancel()66 public void cancel(); 67 } 68