• 最简单的java多线程代码(重写thread或者runnable的run方法)


    http://blog.csdn.net/testcs_dn/article/details/42526549

    java线程使用示例——最简单的线程

    线程使用示例一:

     

    [java] view plain copy
     
    1. public class ThreadTest {  
    2.   
    3.     public static void main(String[] args) {  
    4.         //线程使用示例一:  
    5.         new Thread() {  
    6.             public void run() {  
    7.                 while (true) {  
    8.                     try {  
    9.                         System.out.println("线程输出");  
    10.                           
    11.                         //休眠两秒  
    12.                         Thread.sleep(2 * 1000);  
    13.                     } catch (InterruptedException e) {  
    14.                         e.printStackTrace();  
    15.                     }  
    16.                 }  
    17.             };  
    18.         }.start();  
    19.     }  
    20.   
    21. }  

    线程使用示例二:

    [java] view plain copy
     
    1. //线程使用示例二:  
    2. Thread t1 = new Thread(new Runnable(){  
    3.     public void run(){  
    4.         System.out.println("Mythread 线程t1");  
    5.         while(true){  
    6.             Singleton3 single3 = Singleton3.getInstance(null);  
    7.             System.out.println("线程t1 >> " + single3.toString());  
    8.             try {  
    9.                 Thread.sleep(2000);  
    10.             } catch (InterruptedException e) {  
    11.                 // TODO Auto-generated catch block  
    12.                 e.printStackTrace();  
    13.             }  
    14.         }  
    15.           
    16.     }  
    17. });  
    18. t1.start();  
  • 相关阅读:
    ctags cscope
    u-boot initf_bootstage函数分析
    u-boot log_init函数分析
    u-boot v2018.01 启动流程分析
    DECLARE_GLOBAL_DATA_PTR
    CaptchaCodeManager
    UserTokenManager JwtHelper
    AdminSwagger2Configuration
    logService
    AdminWebSessionManager AdminAuthorizingRealm ShiroConfig ShiroExceptionHandler
  • 原文地址:https://www.cnblogs.com/snailmanlilin/p/7931337.html
Copyright © 2020-2023  润新知