转:wait, sleep, suspend in jsp/javascript
来源:互联网 发布:手机淘宝无线运营中心 编辑:程序博客网 时间:2024/06/05 02:54
转:http://www.jguru.com/faq/view.jsp?EID=47127
Thread.sleep() sends the current thread into the "Not Runnable" state for some amount of time. The thread keeps the monitors it has aquired -- i.e. if the thread is currently in a synchronized block or method no other thread can enter this block or method. If another thread calls t.interrupt() it will wake up the sleeping thread.
Note that sleep is a static method, which means that it always affects the current thread (the one that is executing the sleep method). A common mistake is to call t.sleep() where t is a different thread; even then, it is the current thread that will sleep, not the t thread.
t.suspend() is deprecated. Using it is possible to halt a thread other than the current thread. A suspended thread keeps all its monitors and since this state is not interruptable it is deadlock prone.
object.wait() sends the current thread into the "Not Runnable" state, like sleep(), but with a twist. Wait is called on a object, not a thread; we call this object the "lock object." Before lock.wait() is called, the current thread must synchronize on the lock object; wait() then releases this lock, and adds the thread to the "wait list" associated with the lock. Later, another thread can synchronize on the same lock object and call lock.notify(). This wakes up the original, waiting thread. Basically, wait()/notify() is like sleep()/interrupt(), only the active thread does not need a direct pointer to the sleeping thread, but only to the shared lock object.
==============================================
http://www.ozzu.com/programming-forum/javascript-sleep-function-t66049.html
javascript sleep function:
- /**
- * Delay for a number of milliseconds
- */
- function sleep(delay)
- {
- var start = new Date().getTime();
- while (new Date().getTime() < start + delay);
- }
- 转:wait, sleep, suspend in jsp/javascript
- resume suspend wait sleep
- resume suspend wait sleep
- resume suspend wait sleep
- java wait sleep suspend synchronized
- Thread的wait sleep join yield suspend notify区别
- Thread的wait sleep join yield suspend notify区别
- Thread的wait sleep join yield suspend notify区别收藏
- java线程阻塞(sleep,suspend,resume,yield,wait,notify)
- Java中sleep Wait yield Suspend的区别
- Java多线程之wait,notify,sleep,,yield,join,suspend,resume
- Java线程同步阻塞, sleep(), suspend(), resume(), yield(), wait(), notify()
- java中线程阻塞之sleep、suspend、join、wait、resume、notify方法解析(一)
- 一、Java多线程之wait,notify,sleep,yield,join,suspend,resume
- wait & sleep
- sleep wait
- wait、sleep
- 【think in java】wait和sleep的区别
- 转:在html中引入CSS的方法
- 转:Java, jsp, web app 获得文件路径的代码实例
- 转:HTTP POST GET 本质区别
- 转:jsp usebean session 的等价
- jsp 中用jquery 实现ajax 一个简单例子
- 转:wait, sleep, suspend in jsp/javascript
- 转:Javascript弹出子窗口
- 定制进度条图像
- 转:jsp调用长时间运行java 程序,如何防止浏览器超时断连
- 信息加密试验(基于C的一个简单的对称加密算法实现)
- 图案法显示灰度图————利用Bayer表来对图像值进行二值显示
- 转:关于Endnote使用中的问题
- 转:使用 python 开发 Web Service
- 写算法的时候的心态。