1. // NPCTE fix for bugId 4510777, esc 532372, MR October 2001
  2. // file Task.java created for this bug fix
  3. /*
  4. * @(#)file Task.java
  5. * @(#)author Sun Microsystems, Inc.
  6. * @(#)version 1.2
  7. * @(#)date 01/10/03
  8. *
  9. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  10. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  11. */
  12. package com.sun.jmx.snmp.tasks;
  13. /**
  14. * This interface is implemented by objects that can be executed
  15. * by a {@link com.sun.jmx.snmp.tasks.TaskServer}.
  16. * <p>A <code>Task</code> object implements two methods:
  17. * <ul><li><code>public void run(): </code> from
  18. * {@link java.lang.Runnable}</li>
  19. * <ul>This method is called by the {@link com.sun.jmx.snmp.tasks.TaskServer}
  20. * when the task is executed.</ul>
  21. * <li><code>public void cancel(): </code></li>
  22. * <ul>This method is called by the {@link com.sun.jmx.snmp.tasks.TaskServer}
  23. * if the <code>TaskServer</code> is stopped before the
  24. * <code>Task</code> is executed.</ul>
  25. * </ul>
  26. * An implementation of {@link com.sun.jmx.snmp.tasks.TaskServer} shall call
  27. * either <code>run()</code> or <code>cancel()</code>.
  28. * Whether the task is executed synchronously in the current
  29. * thread (when calling <code>TaskServer.submitTask()</code> or in a new
  30. * thread dedicated to the task, or in a daemon thread, depends on the
  31. * implementation of the <code>TaskServer</code> through which the task
  32. * is executed.
  33. * <p>The implementation of <code>Task</code> must not make any
  34. * assumption on the implementation of the <code>TaskServer</code> through
  35. * which it will be executed.
  36. * <p><b>This API is a Sun Microsystems internal API and is subject
  37. * to change without notice.</b></p>
  38. * @see com.sun.jmx.snmp.tasks.TaskServer
  39. *
  40. * @since 1.5
  41. **/
  42. public interface Task extends Runnable {
  43. /**
  44. * Cancel the submitted task.
  45. * The implementation of this method is Task-implementation dependent.
  46. * It could involve some message logging, or even call the run() method.
  47. * Note that only one of run() or cancel() will be called - and exactly
  48. * one.
  49. **/
  50. public void cancel();
  51. }