📄 dataqueue.java
字号:
/**
* Created at Nov 30, 2008
*/
package com.jdev.app.db.queue;
import java.util.LinkedList;
/**
* <p>Title: DataQueue</p>
* <p>Description: </p>
* @author Lawrence
* @version 1.0
*/
public class DataQueue {
private final static String module = DataQueue.class.getName();
private LinkedList<Object> pool = new LinkedList<Object>();
public int getRecordCount(){
int count = 0;
synchronized(pool){
count = pool.size();
}
return count;
}
public void pushData(Object data) {
synchronized (pool) {
pool.add(data);
pool.notifyAll();
}
}
public Object removeDataFirst() {
synchronized (pool) {
// 如果没有任务,就锁定在这里
while (pool.isEmpty()) {
try {
pool.wait(); //等待解锁
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
return pool.removeFirst();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -