亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? processingthread.java

?? Short Message Peer to Peer
?? JAVA
字號:
/*
 * Copyright (c) 1996-2001
 * Logica Mobile Networks Limited
 * All rights reserved.
 *
 * This software is distributed under Logica Open Source License Version 1.0
 * ("Licence Agreement"). You shall use it and distribute only in accordance
 * with the terms of the License Agreement.
 *
 */
package org.smpp.util;

import org.smpp.SmppObject;

/**
 * Implements <code>Runnable</code> which does a repetitive processing in
 * a cycle and can be started in a thread and stopped in more
 * controlled manner than <code>Thread</code> class.
 * Provides final exception reporting (if there is any).
 *
 * @author Logica Mobile Networks SMPP Open Source Team
 * @version $Revision: 1.1 $
 */
public abstract class ProcessingThread extends SmppObject implements Runnable {
	/**
	 * The name for the thread as displayed in the debug file.
	 */
	private static final String PROCESSING_THREAD_NAME = "ProcThread";

	/**
	 * The instancies of the class are indexed with this index.
	 */
	private static int threadIndex = 0;

	/**
	 * Tells the thread that it should continue processing.
	 * Controls while-cycle in the run method. Can be assigned directly from
	 * the code in case of exceptional situation as oppose to the controlled
	 * stopping of the thread using the <code>stop</code> method.
	 * @see #run()
	 */
	private boolean keepProcessing = true;

	/**
	 * State variable indicating status of the thread. Don't confuse with
	 * <code>keepProcessing</code> which stops the main loop, but
	 * can be set to <code>false</code> far before the end of the loop
	 * using <code>stopProcessing</code> method.
	 * 
	 * @see #keepProcessing
	 * @see #run()
	 * @see #start()
	 * @see #stop()
	 * @see #setProcessingStatus(byte)
	 * @see #isInitialising()
	 * @see #isProcessing()
	 * @see #isFinished()
	 */
	private byte processingStatus = PROC_INITIALISING;

	/**
	 * The processing thread is in initialisation phase.
	 * It's the phase after calling <code>start</code>
	 * but before entering while-loop in the <code>run</code> method.
	 *
	 * @see #processingStatus
	 * @see #isInitialising()
	 */
	private static final byte PROC_INITIALISING = 0;

	/**
	 * The processing thread is in running phase.
	 * It's the phase when the thread is in the while-loop
	 * in the <code>process</code> method or method called from the loop
	 * that method.
	 *
	 * @see #processingStatus
	 * @see #isProcessing()
	 * @see #run()
	 */
	private static final byte PROC_RECEIVING = 1;

	/**
	 * The processing thread is finished.
	 * The finished phase is phase when the thread has exited the while-loop
	 * in the <code>run</code> method. It is possible to run it again
	 * by calling <code>start</code> method again.
	 *
	 * @see #processingStatus
	 * @see #isFinished()
	 */
	private static final byte PROC_FINISHED = 2;

	/**
	 * Object for monitoring the access to the <code>processingStatus</code>
	 * variable.
	 */
	private Object processingStatusLock = new Object();

	/**
	 * Contains the last caught exception.
	 * As there is no means how to catch an exception thrown from the
	 * <code>run</code> method, for case that it's necessary to examine an
	 * exception thrown in <code>run</code> it is stored to this variable.<br>
	 * Descendants of <code>ProcessingThread</code> will use this variable
	 * to store the exception which will cause termination of the thread.
	 * It is also set by <code>run</code> method if it'll catch an
	 * exception when calling <code>process</code>.<br>
	 * The exception is also set by the <code>stopProcessing</code>
	 * method.
	 *
	 * @see #stopProcessing(Exception)
	 * @see #setTermException(Exception)
	 * @see #getTermException()
	 */
	private Exception termException = null;

	/**
	 * The thread which runs the code of this class.
	 */
	private Thread processingThread = null;

	/**
	 * The method which is repeatedly called from the <code>run</code>
	 * method. This is supposed the hearth of the actual processing. The
	 * derived classes should implement their code in this method.
	 */
	public abstract void process();

	/**
	 * Creates new thread and passes it <code>this</code> as
	 * the <code>Runnable</code> to run. Resets private variables to defaults.
	 * Starts the newly created thread.
	 *
	 * @see Thread
	 */
	public void start() {
		debug.enter(DUTL, this, "start()");
		if (!isProcessing()) { // i.e. is initialising or finished
			setProcessingStatus(PROC_INITIALISING);
			termException = null;
			keepProcessing = true;
			processingThread = new Thread(this);
			processingThread.setName(generateIndexedThreadName());
			processingThread.start();
			while (isInitialising()) {
				Thread.yield(); // we're waiting for the proc thread to start
			}
		}
		debug.exit(DUTL, this);
	}

	/**
	 * Stops the receiving by setting flag <code>keepProcessing</code> to false.
	 * Waits until the receiving is really stopped.
	 */
	public void stop() {
		debug.enter(DUTL, this, "stop()");
		if (isProcessing()) {
			stopProcessing(null);
			while (!isFinished()) {
				Thread.yield(); // we're waiting for the proc thread to stop
			}
		}
		debug.exit(DUTL, this);
	}

	/**
	 * Causes stoping of the while-loop in the <code>run</code> method.
	 * Called from <code>stop</code> method or can be used to terminate
	 * the processing thread in case of an exceptional situation while
	 * processing (from <code>process</code> method.)
	 */
	protected void stopProcessing(Exception e) {
		setTermException(e);
		keepProcessing = false;
	}

	/**
	 * Calls <code>process</code> in cycle until stopped.
	 * This method is called from <code>Thread</code>'s code as the code which
	 * has to be executed by the thread.
	 *
	 * @see Thread
	 */
	public void run() {
		debug.enter(DUTL, this, "run()");
		try {
			setProcessingStatus(PROC_RECEIVING);
			while (keepProcessing) {
				process();
				Thread.yield();
			}
		} catch (Exception e) {
			setTermException(e);
			debug.write("ProcessingThread.run() caught unhadled exception " + e);
			event.write(e, "ProcessingThread.run() unhadled exception");
		} finally {
			setProcessingStatus(PROC_FINISHED);
			debug.exit(DUTL, this);
		}
	}

	/**
	 * Should return the name for the thread. Derived classes are expected
	 * to return specific name here from this method.
	 */
	public String getThreadName() {
		return PROCESSING_THREAD_NAME;
	}

	/**
	 * In case there are multiple instancies of the class this generates
	 * and returns instance index.
	 */
	public int getThreadIndex() {
		return ++threadIndex;
	}

	/**
	 * Uses <code>getThreadName</code> and <code>getThreadIndex</code>
	 * to generate unique name for the thread. Called during initialisation
	 * of the thread.
	 */
	public String generateIndexedThreadName() {
		return getThreadName() + "-" + getThreadIndex();
	}

	/**
	 * As there is no means how to catch an exception thrown from
	 * <code>run</code> method, in case that it's necessary to throw an
	 * exception it's rather remembered by calling of this method.
	 *
	 * @param e the exception to remember
	 */
	protected void setTermException(Exception e) {
		termException = e;
	}

	/**
	 * Returns the last exception caught during processing.
	 *
	 * @return the last exception caught during processing
	 */
	public Exception getTermException() {
		return termException;
	}

	/**
	 * Sets the <code>processingStatus</code> to value provided.
	 */
	private void setProcessingStatus(byte value) {
		synchronized (processingStatusLock) {
			processingStatus = value;
		}
	}

	/**
	 * Returns if the <code>processingStatus</code> indicates that
	 * the receiving is in initialisation stage, i.e. the processing loop
	 * has not been entered yet.
	 */
	private boolean isInitialising() {
		synchronized (processingStatusLock) {
			return processingStatus == PROC_INITIALISING;
		}
	}

	/**
	 * Returns if the <code>processingStatus</code> indicates that
	 * the receiving has started, but it didn't finished yet, i.e. the
	 * the thread is still in the processing loop.
	 */
	private boolean isProcessing() {
		synchronized (processingStatusLock) {
			return processingStatus == PROC_RECEIVING;
		}
	}

	/**
	 * Returns if the <code>processingStatus</code> indicates that
	 * the receiving has finished, i.e. the processing loop
	 * has finished.
	 */
	private boolean isFinished() {
		synchronized (processingStatusLock) {
			return processingStatus == PROC_FINISHED;
		}
	}
}
/*
 * $Log: ProcessingThread.java,v $
 * Revision 1.1  2003/07/23 00:29:08  sverkera
 * Imported
 *
 */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美影院精品一区| 欧美刺激脚交jootjob| 久久se这里有精品| 亚洲日本丝袜连裤袜办公室| 日韩一区二区三区在线| aaa国产一区| 日韩av不卡一区二区| 国产精品久久久久三级| 日韩欧美中文字幕公布| 精品视频在线看| 成av人片一区二区| 国产成人自拍高清视频在线免费播放| 亚洲大片精品永久免费| 中文字幕一区二区三区蜜月| 久久丝袜美腿综合| 日韩三级视频在线看| 欧美人妖巨大在线| 欧洲av在线精品| 色综合色狠狠天天综合色| 国产一区视频在线看| 青草国产精品久久久久久| 亚洲自拍偷拍网站| 亚洲视频在线观看三级| 中文字幕视频一区| 国产精品久久久久久亚洲伦 | 色综合咪咪久久| 国产99一区视频免费| 麻豆91小视频| 蜜桃av噜噜一区| 日本成人在线视频网站| 日韩专区欧美专区| 亚洲电影一区二区| 一区二区三区四区不卡视频| 亚洲欧美日韩在线| 国产精品成人免费在线| 国产精品美日韩| 中文字幕乱码一区二区免费| 久久综合成人精品亚洲另类欧美 | 日韩高清国产一区在线| 一区二区高清视频在线观看| 亚洲免费在线播放| 一区二区高清免费观看影视大全| 亚洲黄色免费网站| 亚洲一区二区高清| 午夜精品久久久久久久久| 九九在线精品视频| 久久91精品国产91久久小草| 精品一区二区在线看| 久草在线在线精品观看| 国产一区二区三区免费看| 国产精品综合视频| 成人国产亚洲欧美成人综合网| 成人免费av网站| 在线亚洲人成电影网站色www| 日本国产一区二区| 欧美在线观看视频一区二区三区| 欧美乱妇一区二区三区不卡视频| 7777精品伊人久久久大香线蕉| 日韩亚洲欧美一区二区三区| 欧美mv日韩mv| 国产午夜精品久久| 樱桃视频在线观看一区| 婷婷夜色潮精品综合在线| 裸体歌舞表演一区二区| 国产成人午夜片在线观看高清观看| 成人午夜激情影院| 在线观看不卡一区| 精品欧美乱码久久久久久1区2区 | 久久嫩草精品久久久精品| 日本一二三不卡| 亚洲精选视频免费看| 午夜a成v人精品| 国产精品主播直播| 91丨porny丨国产入口| 91精品国产一区二区三区蜜臀| 久久中文字幕电影| 樱花影视一区二区| 国产在线一区观看| 一本一道久久a久久精品综合蜜臀| 欧美三日本三级三级在线播放| 精品欧美一区二区久久| 亚洲欧美另类图片小说| 蜜臀久久99精品久久久画质超高清| 国产一区二区电影| 欧美午夜电影网| 国产亚洲一二三区| 天堂久久一区二区三区| 成人av电影在线| 欧美一区二区三区性视频| 中文文精品字幕一区二区| 亚洲超丰满肉感bbw| 成人亚洲一区二区一| 欧美福利电影网| 国产免费观看久久| 免费看欧美美女黄的网站| 99亚偷拍自图区亚洲| 精品入口麻豆88视频| 艳妇臀荡乳欲伦亚洲一区| 紧缚奴在线一区二区三区| 在线观看不卡视频| 国产精品毛片无遮挡高清| 久久精品99久久久| 欧美日韩亚洲另类| 亚洲欧美日韩国产综合| 国产在线播放一区三区四| 欧美日韩精品福利| 亚洲免费视频成人| 成人激情小说网站| 久久精品亚洲一区二区三区浴池| 亚洲国产另类av| 91麻豆国产在线观看| 国产欧美一区二区三区在线老狼 | 色先锋久久av资源部| 国产欧美一区二区精品秋霞影院| 日韩黄色小视频| 在线亚洲免费视频| 亚洲色图在线看| 99国产精品久久久久久久久久久| 久久综合色综合88| 麻豆免费看一区二区三区| 欧美在线观看一区| 亚洲永久精品国产| 91黄色激情网站| 亚洲激情欧美激情| 色猫猫国产区一区二在线视频| 亚洲欧美在线视频| 成人国产精品视频| 国产精品网站一区| 大尺度一区二区| 中文字幕欧美国产| 国产盗摄一区二区| 久久久久久影视| 成人综合激情网| 欧美国产精品v| 成人成人成人在线视频| 国产精品久久久久久久久晋中| 国产成人亚洲综合色影视| 欧美激情一区二区| 成人免费看片app下载| 国产精品免费视频网站| 97久久久精品综合88久久| 亚洲欧美欧美一区二区三区| 在线免费不卡视频| 亚洲超碰97人人做人人爱| 欧美日高清视频| 免费久久99精品国产| 欧美精品一区二区三区视频| 国产精品一二三在| 成人免费在线视频| 欧美中文字幕亚洲一区二区va在线| 一区二区三区在线视频免费观看| 精品视频在线看| 蜜臀av在线播放一区二区三区| 日韩欧美激情四射| 国产伦精品一区二区三区免费| 国产精品看片你懂得| 在线精品视频免费观看| 日本欧美肥老太交大片| 欧美精品一区二区高清在线观看 | 欧美日韩成人一区| 免费在线成人网| 久久久综合视频| 99久久99久久久精品齐齐| 亚洲国产精品影院| 精品国产乱码久久久久久牛牛| 国产黄色精品网站| 夜夜嗨av一区二区三区网页| 欧美一区二区三区日韩| 国产盗摄一区二区三区| 亚洲在线观看免费| 久久午夜免费电影| 色噜噜夜夜夜综合网| 看片的网站亚洲| 国产精品国产三级国产普通话蜜臀 | 久久免费视频色| 一本大道av一区二区在线播放 | 国产不卡免费视频| 亚洲六月丁香色婷婷综合久久| 欧美精选一区二区| 国产精品一区二区三区乱码| 亚洲一区二区三区四区不卡| wwww国产精品欧美| 色偷偷一区二区三区| 精东粉嫩av免费一区二区三区| 一区二区在线观看视频在线观看| 日韩午夜激情av| 一本到三区不卡视频| 国产一区二区三区在线观看精品| 一区二区三区四区五区视频在线观看 | 国产91高潮流白浆在线麻豆 | 91美女视频网站| 久久99精品国产麻豆不卡| 亚洲黄色免费电影| 国产三级一区二区| 69堂国产成人免费视频| 91丝袜美腿高跟国产极品老师 | 色999日韩国产欧美一区二区| 精品亚洲porn| 午夜精品一区在线观看| 亚洲私人影院在线观看|