aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question on thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question on thread" Watch "Question on thread" New topic
Author

Question on thread

Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442

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


SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
May Pat
Ranch Hand

Joined: Jul 01, 2002
Posts: 32
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 ]

May P.
janus place
Greenhorn

Joined: Aug 14, 2002
Posts: 8
Veena,
I was able to compile and run the code "as-is". The output is :
1
2
3
4
-Janus
Maria Garcia
Ranch Hand

Joined: Jul 14, 2002
Posts: 86
Veena,
I think you misspelled your class name
check the code you pasted
Maria


SCJP 1.4
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
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

Joined: Jun 20, 2002
Posts: 442

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

Joined: Jun 06, 2002
Posts: 1056
That's indeterminate and implementation-dependent, since the two threads are unsynchronized.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on thread