zoukankan      html  css  js  c++  java
  • 015.5线程常见用法(面试题)

    内容:例子

    class ThreadTest 
    {
        public static void main(String[] args) 
        {
            /*
            new Thread(){
                public void run(){
                    for(int x=0; x<40; x++)
                    {
                        System.out.println(Thread.currentThread().getName()+"...X...."+x);
                    }
                }
            }.start();
            
            Runnable r= new Runnable(){
                public void run(){
                    for(int x=0; x<40; x++)
                    {
                        System.out.println(Thread.currentThread().getName()+"...Y...."+x);
                    }
                }
            };
            new Thread(r).start();
            
            for(int x=0; x<40; x++)
            {
                System.out.println(Thread.currentThread().getName()+"...Z...."+x);
            }
    
            System.out.println("Hello World!");
            */
            //面试题:
            new Thread(new Runnable()
            {
                public void run()
                {
                    System.out.println("runnable run");
                }
            }){
                public void run()
                {
                    System.out.println("subthread run");//执行。
                }
            }.start();
        }
    }
    /*
    class Thread 
    {
        private Runnable r;
        Thread(Runnable r)
        {
            this.r = r;
        }
        public void run()
        {
            if(r!=null)
            {
                r.run();
            }
        }
        public void start()
        {
            run();
        }
    }
    class SubThread extends Thread
    {
        public void run()
        {
            System.out.println("subthread run");
        }
    }
    
    Runnable r = new Runnable()
    {
        public void run()
        {
            System.out.println("runnable run");
        }
    }
    SubThread t = new SubThread(r);
    t.start();
    
    */
  • 相关阅读:
    MATLAB 简单多边形的核
    MATLAB Moravec算子
    MATLAB Sepia Tone滤镜
    MATLAB 异或分类
    MATLAB 神经网络分类
    MATLAB 地图上画经纬度
    MATLAB 最小二乘多项式拟合
    MATLAB 对应点集配准的四元数法
    MATLAB 高斯牛顿法最优化
    MATLAB Levenberg-Marquardt法最优化
  • 原文地址:https://www.cnblogs.com/-nbloser/p/8661697.html
Copyright © 2011-2022 走看看