用线程终止while循环
2011-02-28 22:39
253 查看
public class StartTest { public static void main(String[] args) { Server s = new Server(); s.start(); s.end(); } } public class Server { private Thread thread; public void start(){ MyThread myThread = new MyThread(); thread = new Thread(myThread); thread.setDaemon(true); thread.start(); } public void end(){ thread.interrupt(); } private class MyThread implements Runnable{ public void run(){ int i = 0; while(true){ System.out.println(i++); } } } }
相关文章推荐
- 编写程序,将用分钟表示的时间转换成以小时 和分钟表示的时间。使用#define来创建一个代 表60的符号常量。使用while循环来允许用户重 复键入值并当键入一个小于等于0的时间是终止循环。
- linux下模拟按键kbhit(),检测按键终止while(1)死循环
- 并行编程之多线程共享非volatile变量,会不会可能导致线程while死循环
- 终结者:终止线程循环的方式
- java用while循环设计轮询线程的性能问题
- java用while循环设计轮询线程的性能问题
- 编写一段程序,从标准输入读取string对象的序列直到连续出现两个相同的单词或者所有单词都读完为止。使用while循环一次读取一个单词,当一个单词连续出现两次是使用break语句终止循环。输出连续重复出现的单词,或者输出一个消息说明没有人任何单词是重复出现的。
- 多线程:为什么在while循环中加入System.out.println,线程可以停止
- while(scanf("%d",&n)!=EOF)如何在控制台终止循环输入
- 并行编程之多线程共享非volatile变量,会不会可能导致线程while死循环
- C++常用概念——while循环时终止输入(Ctrl+Z,Ctrl+C,Ctrl+D(EOF))
- wait()方法写在while循环中可以在线程接到通知后再一次判断条件
- 多线程(四)循环线程的终止
- c# 线程启动while(true) 死循环,里边的return导致线程退出情况,查错
- 导致下面的while循环终止的原因是什么?
- LCC编译器的源程序分析(30)while循环语句
- php while循环
- javascript中的while循环
- python中的while循环
- tar ,cpio打包解压. shell脚本for,while,until循环. rpm包管理,select循环菜单,函数function,yum