其他分享
首页 > 其他分享> > 6、[简答题] 【多线程】 请在指定位置插入代码实现打印输出1-99。

6、[简答题] 【多线程】 请在指定位置插入代码实现打印输出1-99。

作者:互联网

6、[简答题]

【多线程】

请在指定位置插入代码实现打印输出1-99。

 

public class Test06 {
public int start = 1;
public int end = 99;
public static void main (String[] args) {
new Test06().method();
}
public void method() {
//请在此处插入代码,实现功能
Thread t = new Thread( a );
t.start();
}
}

 

package day_07_test;
//6、[简答题]
//【多线程】
//请在指定位置插入代码实现打印输出1-99。
public class Test06 {
    public int start = 1;
    public int end = 99;
    public static void main (String[] args) {
        new Test06().method();
    }
    public void method() {
//请在此处插入代码,实现功能
       Runnable a = ()->{
            for (int i = start; i <end ; i++) {
                System.out.println(i);
            }
        };
  /*      Runnable runnable = new Runnable() {
            @Override
            public void run() {
                for (int i =start; i <end ; i++) {
                    System.out.println(i);
                }
            }
        };*/
        Thread t = new Thread( a );
        t.start();
    }
}

标签:打印输出,简答题,int,method,99,start,多线程,Test06,public
来源: https://www.cnblogs.com/x-house/p/16170230.html