MyThread
来源:互联网 发布:广州入学积分怎么算法 编辑:程序博客网 时间:2024/06/04 01:08
package org.sf.thread;
/**
* wait sleep wait必须在锁里面才可以被唤醒,wait 等待后是可以被唤醒,而sleep等待多长时间就多长时间
* @author sfit0734
*
*/
public class MyThread {
public static void main(String[] args) {
Runnable runnable = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
synchronized (this) {
try {
wait(6000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("wait finished!");
}
}
};
Thread t = new Thread(runnable, "WATCHDOG");
t.setDaemon(true);
t.start();
while(t.isAlive()){
}
}
}
/**
* wait sleep wait必须在锁里面才可以被唤醒,wait 等待后是可以被唤醒,而sleep等待多长时间就多长时间
* @author sfit0734
*
*/
public class MyThread {
public static void main(String[] args) {
Runnable runnable = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
synchronized (this) {
try {
wait(6000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("wait finished!");
}
}
};
Thread t = new Thread(runnable, "WATCHDOG");
t.setDaemon(true);
t.start();
while(t.isAlive()){
}
}
}
0 0
- MyThread
- myThread
- MyThread
- MyThread::run()
- class MyThread implements Runnable
- MyThread线程基本训练
- QT Error undefined reference to `vtable for MyThread'
- py 使用MyThread继承重写线程类实现多线程编程
- 安卓简单技术-MyThread实现简单定时
- 4月10日,MyThread,每日20行。
- 4月11日,MyThread,每日20行。
- python 写一个Mythread能返回线程执行的结果
- 【已解决】Eclipse莫名出现The type MyThread is already defined错误
- 自定义类MyThread 实现Runnable接口,主函数创建5个线程,自定义线程类的构造函数输出 创建线程X
- 自定义类MyThread 实现Runnable接口,主函数创建5个线程,自定义线程类的构造函数输出 创建线程X -002
- 自定义类MyThread 实现Runnable接口,主函数创建5个线程,自定义线程类的构造函数输出 创建线程X * run方法内统计每个线程 一共6次
- 第二种:自定义类MyThread 实现Runnable接口,主函数创建5个线程,自定义线程类的构造函数输出 创建线程X * run方法内统计每个线程 一共6次
- JackrabbitTest
- Unicode下CString和char *之间的互相转换
- 常用到的手机功能调用,录音操作等,获得视频缩略图,图片的剪裁
- ios学习流程
- 网站收藏
- MyThread
- HTML Parser Jsoup - 网页抓取百度百科信息的例子
- ThreadJoinTest
- 对于一个做编程的人呢,应该懂自己才行
- char*,const char*和string的相互转换
- ThreadNotify_Pro_Con
- Linux下安装、开启Telnet服务
- ThreadNotify_Pro_Con2
- Linux系统上yum与apt对比学习