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

📄 waitqueue.java

📁 RFID复杂事件处理系统的研究实验
💻 JAVA
字号:
package test;

import java.util.LinkedList;

public class WaitQueue implements EventReceiver{
	
	private LinkedList<P_Event> queue=new LinkedList<P_Event>();
    private static int m=0;
	
	WaitQueue(){}
	

	public synchronized void acceptEvent(P_Event e)
	{
		queue.addLast(e);
		
		this.notify();
	}
	
	public synchronized P_Event getEvent()
	{
		try
		{
			if(queue.size()==0) 
			{
				this.wait();
			}			
		}
	    catch (InterruptedException e)
	    {
		    // TODO Auto-generated catch block
		    e.printStackTrace();
	    }
	    return queue.removeFirst();
	}
	
	public synchronized P_Event getEvent0()
	{
		try
		{
			if(queue.size()<=m) 
			{
				this.wait();
			}			
		}
	    catch (InterruptedException e)
	    {
		    // TODO Auto-generated catch block
		    e.printStackTrace();
	    }
	    return queue.get(m++);
	}
	
	

	
	public int getsize()
	{
		return queue.size();
	}
	public LinkedList<P_Event> getQueue() {
		return queue;
	}

}

⌨️ 快捷键说明

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