noclassdeffounderror在运行时获取此错误?

qoefvg9y  于 2021-07-12  发布在  Java
关注(0)|答案(1)|浏览(506)

线程“main”java.lang.noclassdeffounderror中出现异常:mythread(错误名称:mythread),位于java.base/java.lang.classloader.defineclass1(本机方法),位于java.base/java.lang.classloader.defineclass(classloader)。java:1010)在java.base/java.security.secureclassloader.defineclass(secureclassloader。java:150)在java.base/jdk.internal.loader.builtinclassloader.defineclass(builtinclassloader。java:855)在java.base/jdk.internal.loader.builtinclassloader.findclassonclasspathornull(builtinclassloader。java:753)在java.base/jdk.internal.loader.builtinclassloader.loadclassornull(builtinclassloader。java:676)在java.base/jdk.internal.loader.builtinclassloader.loadclass(builtinclassloader。java:634)在java.base/jdk.internal.loader.classloaders$appclassloader.loadclass(classloaders。java:182)在java.base/java.lang.classloader.loadclass(classloader。java:519)在multirunable.main(multirunable.main)。java:15)
进程已完成,退出代码为1
code:-

class MyThread implements Runnable{
    @Override
    public void run() {
        System.out.println("I am a thread 1 not a thread 2");
    }
}
class MyThread2 implements Runnable{
    @Override
    public void run() {
        System.out.println("I am a thread 2 not a thread 1");
    }
}
public class multirunable {
    public static void main(String[] args) {
        MyThread t1= new MyThread();
        Thread w1= new Thread(t1);
        Mythread2 t2=new Mythread2();
        Thread w2=new Thread(t2);

        w1.start();
        w2.start();
    }
}
kx5bkwkv

kx5bkwkv1#

你用你的主要方法写的 Mythread2 但你得给它起个名字 MyThread2 因为那是你的runnable类的同一个名字。

相关问题