文档章节

InterruptableJob.java

绿林小子
 绿林小子
发布于 2015/11/25 17:30
字数 477
阅读 113
收藏 0
/* 
 * Copyright 2004-2005 OpenSymphony 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 * use this file except in compliance with the License. You may obtain a copy 
 * of the License at 
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0 
 *   
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
 * License for the specific language governing permissions and limitations 
 * under the License.
 * 
 */
 
/*
 * Previously Copyright (c) 2001-2004 James House
 */
package org.quartz;
 
/**
 * <p>
 * The interface to be implemented by <code>{@link Job}s</code> that provide a 
 * mechanism for having their execution interrupted.  It is NOT a requirment
 * for jobs to implement this interface - in fact, for most people, none of
 * their jobs will.
 * </p>
 * 
 * <p>
 * The means of actually interrupting the Job must be implemented within the
 * <code>Job</code> itself (the <code>interrupt()</code> method of this 
 * interface is simply a means for the scheduler to inform the <code>Job</code>
 * that a request has been made for it to be interrupted). The mechanism that
 * your jobs use to interrupt themselves might vary between implementations.
 * However the principle idea in any implementation should be to have the
 * body of the job's <code>execute(..)</code> periodically check some flag to
 * see if an interruption has been requested, and if the flag is set, somehow
 * abort the performance of the rest of the job's work.  An example of 
 * interrupting a job can be found in the java source for the  class 
 * <code>org.quartz.examples.DumbInterruptableJob</code>.  It is legal to use
 * some combination of <code>wait()</code> and <code>notify()</code> 
 * synchronization within <code>interrupt()</code> and <code>execute(..)</code>
 * in order to have the <code>interrupt()</code> method block until the
 * <code>execute(..)</code> signals that it has noticed the set flag.
 * </p>
 * 
 * <p>
 * If the Job performs some form of blocking I/O or similar functions, you may
 * want to consider having the <code>Job.execute(..)</code> method store a
 * reference to the calling <code>Thread</code> as a member variable.  Then the
 * impplementation of this interfaces <code>interrupt()</code> method can call 
 * <code>interrupt()</code> on that Thread.   Before attempting this, make
 * sure that you fully understand what <code>java.lang.Thread.interrupt()</code> 
 * does and doesn't do.  Also make sure that you clear the Job's member 
 * reference to the Thread when the execute(..) method exits (preferrably in a
 * <code>finally</code> block.
 * </p>
 * 
 * @see Job
 * @see StatefulJob
 * @see Scheduler#interrupt(String, String)
 * @see org.quartz.examples.example7.DumbInterruptableJob
 * 
 * @author James House
 */
public interface InterruptableJob extends Job {
 
    /*
     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Interface.
     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     */
 
    /**
     * Called by the <code>{@link Scheduler}</code> when a user
     * interrupts the <code>Job</code>.
     * 
     * @return void (nothing) if job interrupt is successful.
     * @throws UnableToInterruptJobException
     *           if there is an exception while interrupting the job.
     */
    public void interrupt()
            throws UnableToInterruptJobException;
 
     
}



© 著作权归作者所有

上一篇: StatefulJob源码
下一篇: Job层次结构
绿林小子
粉丝 5
博文 131
码字总数 45566
作品 0
福州
私信 提问

暂无文章

Tensorflow 2.0安装

Tensorflow2.0安装环境: Ubuntu 16.04或更高(64位) Windows 7或者更高(64位,且支持python3) 安装Tensorflow 2.0 GPU版本的需要安装NVIDIA相关软件包: NVIDIA驱动 :版本必须410.x或更...

JosiahMg
20分钟前
4
0
TL138/1808/6748F-EasyEVM开发板硬件、CPU、FLASH、RAM

TL138/1808/6748F-EasyEVM是广州创龙基于SOM-TL138/SOM-TL1808/SOM-TL6748F核心板开发的一款开发板。由于SOM-TL138/SOM-TL1808/SOM-TL6748核心板管脚兼容,所以此三个核心板共用同一个底板。...

Tronlong创龙
27分钟前
4
0
百度嵌入式AI解决方案EdgeBoard之内存驱动设计介绍

1. 背景介绍 由于 FPGA 具备可编程和高性能计算的特点,基于FPGA硬件的AI计算加速,正广泛地应用到计算机视觉处理领域。其中极具代表性的部署方式之一就是使用FPGA和CPU组合构成异构计算系统...

AI君
33分钟前
6
0
开放应用模型(OAM):全球首个云原生应用标准定义与架构模型

Kubernetes 项目作为容器编排领域的事实标准, 成功推动了诸如阿里云 Kubernetes (ACK)等云原生服务的迅速增长。但同时我们也关注到,Kubernetes 的核心 API 资源比如 Service、Deploymen...

Mr_zebra
36分钟前
4
0
《Linux操作系统-Exynos4412》编译和安装Busybox

开发环境:Exynos4412-iTOP-4412开发板 现在 Busybox 的配置已经完成了,接下来开始编译 Busybox,在 Ubuntu 的终端输入 “make”命令开始编译 Busybox,如下图。 下图为编译过程中的截图。 ...

书白
39分钟前
4
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部