📄 persistqueue.java
字号:
package com.gctech.sms.sp.cms.core;
import com.gctech.sms.sp.cms.msg.*;
import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
public class PersistQueue
{
LinkedQueue queue = null;
String fileLocation = "defaultPersist.db";
public PersistQueue(boolean isPersist)
{
queue = new LinkedQueue();
}
/**
* 持久化队列,并制定保存队列的文件名字
* @param fileLocation
*/
public PersistQueue(String fileLocation)
{
}
public boolean isEmpty()
{
return queue.isEmpty();
}
public void putMessage(Message msg) throws InterruptedException
{
try
{
queue.put(msg);
}
catch(InterruptedException ie)
{
throw ie;
}
}
public Message takeMessage() throws PlatformException
{
try
{
return (Message)queue.take();
}
catch(InterruptedException ie)
{
throw new PlatformException(ie.getMessage());
}
}
public Message takeMessage(long time) throws InterruptedException
{
try
{
return (Message)queue.poll(time);
}
catch(InterruptedException ie)
{
throw ie;
}
}
public static void main(String[] args) {
// PersistQueue persistQueue1 = new PersistQueue();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -