一个程序中启动了多个线程后,怎么去控制这些线程?

ycscsjj 2009-12-15 09:12:56
一个程序中启动了多个线程后,怎么去控制这些线程?
...全文
120 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
snoowball 2009-12-16
  • 打赏
  • 举报
回复
用PriorityQueue自己搞优先级,interrupt低优先权的线程:)
小梁_unique 2009-12-15
  • 打赏
  • 举报
回复
setpriority()
weihthchk 2009-12-15
  • 打赏
  • 举报
回复
这个问题真是……好像哲学一样空泛……
godismydaughter 2009-12-15
  • 打赏
  • 举报
回复
线程组是比较好。
一头头 2009-12-15
  • 打赏
  • 举报
回复
priority is really a bad idea for controlling the threads.

Java's scheduling and priority models are weak; in particular

1. no guarantee is given that the highest priority runnable thread is always executing;

2. equal priority threads may or may not be time sliced; and

3. where native threads are used, different Java priorities may be mapped to the same operating system priority


use Thread Groups or Thread Manager to control your threads.
ghd2000 2009-12-15
  • 打赏
  • 举报
回复
设置优先级!
sun90cn 2009-12-15
  • 打赏
  • 举报
回复
设置优先级是控制线程执行的顺序
godismydaughter 2009-12-15
  • 打赏
  • 举报
回复
设置优先级。

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧