⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 00e46bced569001c1989d8a2fa4db5ce

📁 这是我自己照着书上敲的
💻
字号:
/*
 * 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 MyTread(Applet1 main,String name)
	{
		count=0;
		label=new Label("Threas"+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 + -