解决方案 »
- Java程序执行完时,如何返回一个数值?
- 请教名词解释:栈 、堆 、常量池、 方法区域 尽量详细点 谢谢了!
- how to use getOutputStream() method for Process class???
- 如何判断JTextArea对象脏了?
- 初学JAVA,请问各位哪本数据结构(JAVA版)比较好?
- 为什么我下载了JDK安装后却在DOS下无法编译?听说要设置环境变量?那怎样设置呢?谢谢
- 送分
- ·····进门就送分!····· 如何运行一个包含多国语言的SQL语句
- JBuilder5的硬件要求???
- 大侠帮帮小虾米
- 今天写了一个计算器,出现了问题,求大侠帮忙解决,先谢谢了
- 自己无聊根据视频写了一个抢票的的程序,但是出了点问题
public E take() throws InterruptedException {
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
try {
while (count == 0)
notEmpty.await();
} catch (InterruptedException ie) {
notEmpty.signal(); // propagate to non-interrupted thread
throw ie;
}
E x = extract();
return x;
} finally {
lock.unlock();
}
}
当你put的时候,队列里已经满它就会锁死。public void put(E e) throws InterruptedException {
if (e == null) throw new NullPointerException();
final E[] items = this.items;
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
try {
while (count == items.length)
notFull.await();
} catch (InterruptedException ie) {
notFull.signal(); // propagate to non-interrupted thread
throw ie;
}
insert(e);
} finally {
lock.unlock();
}
}
notEmpty.signal()
BlockingQueue<String> blockQueue = new ArrayBlockingQueue<String>(Integer.MAX_VALUE );
当队列中没有数据的时候take会一直堵塞,直到有线程往队列中put,
当队列已经满了的时候put会一直堵塞,直到有线程从队列中take.
只能介绍这么多的原理了。希望能帮助到我,这是我写socket,多线程编程的一点经验。
当队列中没有值是wait(),当队列中有值是再,调用 notify.或使用lock锁。
2.在A库中可以直接引用B库的表进行查询操作。
3.再根据查询做相关的插入。具体dblink的创建请百度