Java 如何以100行显示线程,每行长度为100个字符

Java 如何以100行显示线程,每行长度为100个字符,java,multithreading,Java,Multithreading,如何在100行中显示线程,每行长度为100个字符 public class CustomThread extends Thread{ private Thread t; private String threadName; CustomThread( String threadName){ this.threadName = threadName; System.out.println("Creating " + thread

如何在100行中显示线程,每行长度为100个字符

    public class CustomThread extends Thread{

    private Thread t;
    private String threadName;

    CustomThread( String threadName){
        this.threadName = threadName;
        System.out.println("Creating " +  threadName );
    }
    public void run() {
        System.out.println("Running " +  threadName );
        try {
            for(int i = 0; i < 100; i++) {
                for (int j = 0; j < 100; j++) {
                    System.out.println(threadName);
                    Thread.sleep(50);
                }
                System.out.println("\n");
            }
        } catch (InterruptedException e) {
            System.out.println("Thread " +  threadName + " interrupted.");
        }
        System.out.println("Thread " + threadName + " exiting.");
    }

    public void start ()
    {
        System.out.println("Starting " +  threadName );
        if (t == null)
        {
            t = new Thread (this, threadName);
            t.start ();
        }
    }
}

这个字符是“1”。但是如何在100个字符上显示100行呢?我的代码无效

为什么不给自己的线程命名呢

    Thread.currentThread().setName("Bob");
    System.out.println(Thread.currentThread().getName());
无论如何,要打印行,请更改

System.out.println(threadName);


println()
始终包含一个新行字符

为什么不命名线程?主题外:为什么类
扩展线程
而不是
实现可运行的
?如何创建这些线程?你已经有了一个接受名称的构造函数?你说你的代码不工作是什么意思?输出是什么?对不起,我编辑了我的问题。谢谢你的回答。@piduna.A。我编辑了我的答案。无论如何,你应该发布一个全新的问题。
System.out.println(threadName);
System.out.print(threadName);