Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on thread  RSS feed

 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The above code compiles fine .But throwing following exception.
Exception in thread "main" java.lang.NoClassDefFoundError: threadtest (wrong name: ThreadTest)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:403)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:10
1)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$1(URLClassLoader.java:216)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:191)
at java.lang.ClassLoader.loadClass(ClassLoader.java:280)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:275)
at java.lang.ClassLoader.loadClass(ClassLoader.java:237)

I have defined class in filename threadtest.java not ThreadTest.java
Can anybody tell what's wrong with this code?
Veena
 
May Pat
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Veena, I tried the code and didn't get any compiler error. The code prints:
1
2
3
4
[ August 15, 2002: Message edited by: May Pat ]
 
janus place
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Veena,
I was able to compile and run the code "as-is". The output is :
1
2
3
4
-Janus
 
Maria Garcia
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Veena,
I think you misspelled your class name
check the code you pasted
Maria
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wondered,y my jvm is not printing o/p to me .I had a java file with the name ThreadTest.java......but now I tried again it is working.I didn't do anything.I couldn't know what was the problem...!
Veena
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What priority main thread will have.Coz the above code prints
true
1
2
3
4
Shouldn't it print
1
2
3
4
true?
Thanks
Veena
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's indeterminate and implementation-dependent, since the two threads are unsynchronized.
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The default priority of any thread is Thread.NORM_PRIORITY, which is 5. A thread inherits the priority of its parent thread. Both threads here have the same priority, but since the thread scheduler is implementation dependent, the output will be unpredictable.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!