use sleep() to gain thread predictability
来源:互联网 发布:淘宝客怎样推广店铺 编辑:程序博客网 时间:2024/04/28 16:45
package HeadFirstJava;class MyRunnable implements Runnable { public void run() { go(); } public void go() { try { Thread.sleep(2000); } catch(InterruptedException ex) { ex.printStackTrace(); } doMore(); } public void doMore() { System.out.println("top of the stack"); }}class ThreadTestDrive { public static void main(String[] args) { MyRunnable theJob = new MyRunnable(); Thread t = new Thread(theJob); t.start(); System.out.println("back in main"); }}
back in main
top of the stack
// notice the time pause between 'back in main' & 'top of the stack',
// which is about 2 seconds
0 0
- use sleep() to gain thread predictability
- how to use thread
- How to use Thread
- Multi-Thread 1: how to use synchronized
- thread.sleep()
- Thread.Sleep
- thread.sleep()
- Thread.Sleep
- Thread.sleep() & SystemClock.sleep()
- Thread.sleep() & SystemClock.sleep()
- 9 Ways to Gain Your Visitors Respect
- Thread.sleep()和Thread.currentThread().sleep()区别
- Thread.sleep()和Thread.currentThread().sleep()区别
- Thread.sleep()和Thread.currentThread().sleep()区别
- Thread.sleep 与Thread.currentThread.sleep
- Do not use shared variable to check thread status
- Use event to terminate a windows thread gracefully (MSDN sample)
- How to: Use a Thread Pool (C# Programming Guide)
- 猜拳游戏GuessGame源码
- Android 开源框架Universal-Image-Loader完全解析(一)--- 基本介绍及使用
- OC特有语法—Block
- PHP 邀请码类
- MS DOS 命令大全
- use sleep() to gain thread predictability
- iOS 视图封装及适配
- Java性能优化
- Optimal ArrayMultiplication Sequence
- Android开发之设置60s倒计时
- CocoaPods操作
- 纯css3实现的圆形进度条
- 立贴见证
- METIS-一种图切分的软件包(简介)