RunnableTimerTask.java revision 5c099afa7c9361afc2f4477fec0e3018588d7840
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * The contents of this file are subject to the terms
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * of the Common Development and Distribution License
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * (the License). You may not use this file except in
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * compliance with the License.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * You can obtain a copy of the License at
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * See the License for the specific language governing
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * permission and limitations under the License.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * When distributing Covered Code, include this CDDL
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Header Notice in each file and include the License file
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * If applicable, add the following below the CDDL Header,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * with the fields enclosed by brackets [] replaced by
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * your own identifying information:
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * $Id: RunnableTimerTask.java,v 1.2 2008/06/25 05:52:52 qcheng Exp $
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * RunnableTimerTask is a TimerTask which will use Recoverable interface
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * whenever Exception or Error may stop the running Timer or make the Timer to
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * an unknown state.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterpublic class RunnableTimerTask extends RecoverableTimerTask {
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Constructor of RunnableTimerTask
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @param target The runnable interface to be run
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Assigns the runnable interface to this RunnableTimerTask
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @param target The runnable to assign
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster public synchronized void setRunnable(Runnable target) {
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Returns the runnable interface from this RunnableTimerTask
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @return Runnable interface assoicated with this RunnableTimerTask
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * The run method with error handling and recovery.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster public void run() {
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster synchronized (this) {
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster // log something here
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster synchronized (this) {
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster // log something here
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster // log something here
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster synchronized (this) {
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster throw new Error(t);