Hi
-
class NewThread implements Runnable {
-
Thread t;
-
-
NewThread() {
-
t = new Thread(this, "Demo Thread");
-
System.out.println("Child Thread:" + t);
-
t.start();
-
}
-
-
public void run() {
-
try {
-
for (int i = 5; i > 0; i--) {
-
System.out.println("Child Thread:" + i);
-
Thread.sleep(500);
-
}
-
} catch (InterruptedException e) {
-
System.out.println("Child interuppted.");
-
}
-
System.out.println("Exiting child Thread");
-
}
-
}
-
-
class ThreadDemo {
-
public static void main(String[] args) {
-
new NewThread();
-
try {
-
for (int i = 5; i > 0; i--) {
-
System.out.println("Main Thread:" + i);
-
Thread.sleep(1000);
-
}
-
} catch (InterruptedException e) {
-
System.out.println("Main thread interuppted.");
-
}
-
System.out.println("Main thread exiting.");
-
}
-
}
-
When i try to run it on command prompt i get this error.
c:\java>javac ThreadDemo.java
c:\java>java ThreadDemo
Exception in thread "main" java.lang.NoClassDefFoundError: ThreadDemo
Caused by: java.lang.ClassNotFoundException: ThreadDemo
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
c:\java>
CAN YOU PLEASE GUIDE ME WHERE I AM WRONG.
Regards,
Neha