zoukankan      html  css  js  c++  java
  • 线程的优先级

    设置线程的优先级 setPriority()设置线程的优先级

    package com.loaderman.threadmethod;
    
    
    public class Demo_Priority {
    
    
    /**
    
    * @param args
    
    */
    
      public static void main(String[] args) {
    
        Thread t1 = new Thread(){
    
        public void run() {
    
            for(int i = 0; i < 100; i++) {
    
                System.out.println(getName() + "...aaaaaaaaa" );
    
              }
    
          }
    
      };
    
    
      Thread t2 = new Thread(){
    
        public void run() {
    
          for(int i = 0; i < 100; i++) {
    
              System.out.println(getName() + "...bb" );
    
          }
    
        }
    
      };
    
    
      //t1.setPriority(10); 设置最大优先级
    
      //t2.setPriority(1);
    
    
      t1.setPriority(Thread.MIN_PRIORITY); //设置最小的线程优先级
    
      t2.setPriority(Thread.MAX_PRIORITY); //设置最大的线程优先级
    
    
      t1.start();
    
      t2.start();
    
      }
    
    
    }
    
  • 相关阅读:
    前端下载(导出)功能实现
    cookie和session
    MySQL常用数据类型
    Spring AOP小结
    Spring IoC小结
    BST、B树、B+树、B*树
    java中的匿名内部类小结
    java中的内部类小结
    Collections类常用方法总结
    Java垃圾回收小结
  • 原文地址:https://www.cnblogs.com/loaderman/p/6411154.html
Copyright © 2011-2022 走看看