threadpri.java

来自「一个十分好的java基础学习的课件」· Java 代码 · 共 21 行

JAVA
21
字号
public class ThreadPri
{
    public static void main(String args[ ])
    {
        MyThread th[ ]=new MyThread[3];
        for(int i=0;i<3;i++)
            th[i]=new MyThread( );
        for(int i=0;i<3;i++)
            th[i].start( );
        th[0].setPriority(Thread.MAX_PRIORITY);
        th[2].setPriority(Thread.MIN_PRIORITY);
    }
}
class MyThread extends Thread
{
    public void run( )
    {
        for(int i=0;i<2;i++)
            System.out.println(getName( )+"线程的优先级是:\t"+getPriority( )+"。");
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?