?? priorityapplet.java
字號:
/*
* Created on 2007-9-23
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.awt.*;
import java.applet.*;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class PriorityApplet extends Applet
{
public void init()
{
MyThread thread1=new MyThread(this,"1");
MyThread thread2=new MyThread(this,"2");
MyThread thread3=new MyThread(this,"3");
MyThread thread4=new MyThread(this,"4");
MyThread thread5=new MyThread(this,"5");
thread1.setPriority(Thread.NORM_PRIORITY);
thread2.setPriority(Thread.NORM_PRIORITY-1);
thread3.setPriority(Thread.NORM_PRIORITY-2);
thread4.setPriority(Thread.NORM_PRIORITY-3);
thread5.setPriority(Thread.NORM_PRIORITY-4);
thread1.start();
thread2.start();
thread3.start();
thread4.start();
thread5.start();
}
}
class MyThread extends Thread
{
Label label;
int count;
public MyThread(PriorityApplet main,String name)
{
count=0;
label=new Label("Thread"+name+":0");
main.add(label);
setName(name);
}
public void run()
{
while(count<1000)
{
count++;
label.setText("Thread"+this.getName()+":"+Integer.toString(count));
for(int i=0;i<65335;i++)
for(int j=0;j<1000;j++)
;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -