Java多线程编程详解线程状态变迁与优先级控制实践指南.pptVIP

  • 0
  • 0
  • 约4.02千字
  • 约 19页
  • 2026-07-16 发布于江苏
  • 举报

Java多线程编程详解线程状态变迁与优先级控制实践指南.ppt

;目录;任务十一用数组存放信息(使用数组);任务二十一简明清楚的菜单(使用菜单和其它常用事件);任务二十八线程的生命周期与优先级

(线程的状态与调度);内容提要;28.1跟我做:“吃苹果”的线程调度;28.2实现方案;28.2实现方案;程序代码

package.task28;

publicclassEatApple{

intf=5;//一种盘子里最多能够放5个苹果数量

intn=0;//一种盘子里剩下的苹果数量

intnum;//最多能够放的苹果数量

ints=0;//已经放入的苹果数量

intz=0;//已经取走的苹果数量

publicEatApple(intnum){

this.num=num;}

synchronizedvoidput(){

while(n=f){

try

{System.out.println(Thread.currentThread().getName()+等候放苹果);

wait();

}catch(InterruptedExceptione){}

}

s=s+1;

if(s=num)Thread.currentThread().stop();

n=n+1;

文档评论(0)

1亿VIP精品文档

相关文档