本帖最后由 小泉真也 于 2014-1-16 22:24 编辑
- class Ticket implements Runnable
- {
- private int tick = 100;
-
- public void run()
- {
- while(true)
- {
- if(tick > 0)
- { System.out.println(Thread.currentThread().getName() + "sale : " + tick--); }
- }
- }
-
- }
- class TicketTest1
- {
- public static void main(String[] args)
- {
-
- Ticket t = new Ticket();
-
- Thread t1 = new Thread(t);
- Thread t2 = new Thread(t);
- Thread t3 = new Thread(t);
- Thread t4 = new Thread(t);
-
- t1.start();
- t2.start();
- t3.start();
- t4.start();
-
-
- }
- }
复制代码 代码如上,编译能通过,但是运行就出现了错误
错误如下
Exception in thread "main" java.lang.NoClassDefFoundError: ThreadTest1
Caused by: java.lang.ClassNotFoundException: ThreadTest1
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: ThreadTest1. Program will exit.
==看得不是很明白啊
|