⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 signalmanager.java

📁 java信号处理程序
💻 JAVA
字号:
package kh.signal;import java.util.*;/**   The central clearinghouse for JavaSignals.   Copyright 1998 Kevin Hester, kevinh@acm.org      Commerical use prohibited - non commercial distribution is OK.   Contact the author for further information.*/public class SignalManager     {	/**	   Adds a listener which is interested in certain signals.	   @param listener the instance which would like to be informed on a signal.	*/	public static void addListener(SignalListener listener)	    {		startManager();		for(int i = listener.SIG_MIN; i <= listener.SIG_MAX; i++)			if(listener.isInterested(i))				interestMask |= (1 << i);		// System.out.println("JAVA: interest mask: " + interestMask);		listeners.addElement(listener);				setInterestMask();		}	/**	   Removes a listener.	   @param listener the listener to remove.	*/	public static void removeListener(SignalListener listener)	    {		// FIXME - remove things from the interest mask		listeners.removeElement(listener);		}	private static void startManager()	    {		if(managerStarted)			return;		// Load our native code - I prefer to only load native code once the user		// has called addListener.		System.loadLibrary("Signal");		new SignalManagerThread();		managerStarted = true;		}	/**	   A query function to provide runtime version checking	*/	public static String getVersion()	    {		return "Java Signals Version 1.0 - Copyright 1998 Kevin Hester, kevinh@acm.org";		}	/**	   Native code which blocks until a signal is received.	*/	static native int waitForSignal();	/**	   Native code to inform C land of what signals we are interested in.	   FIXME - make this synchronized!!!!	*/    private static native void setInterestMask();	static Vector listeners = new Vector();    private static int interestMask = 0;    private static boolean managerStarted = false;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -