/*********what is wrong?why is'nt the new thread starting up?*********/
posted 11 years ago
Hey i Wrote a java File and named it Thread.java and to my surprise it compiled and executed?? how can it be possible? because when we have a inbuilt Thread class it shouldn't have allowed this right??
Originally posted by prasanna sheregar: Hey i Wrote a java File and named it Thread.java and to my surprise it compiled and executed?? how can it be possible? because when we have a inbuilt Thread class it shouldn't have allowed this right??
the Java Thread class is in java.lang
you likely created a class in a custom package or the default package
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
hi, the problem was i had earlier written a Thread.java file in the default package so when i extended my program it extended from the Thread File which i developed instead of extending from java.lang.Thread
So how does the Java system decided to Extend from my developed Thread class instead of java.lang .Thread
suppose i create a new dummy Thread class in the default package and write one more class which extends Thread . Now which one will Java system take 1> the one which i wrote 2> java.lang.Thread
Hi Prasanna ... Thread is not a reserved word for Java , then it's possible to create a class named Thread .. Why is YouThread extending from your class Thread ? Because you put it in the same package where YouThread.java is and the classes in the package (default or others ) have precedence over other class sources..including the API.
Then , YouThread finds Thread in the same package and extends it . If you move your class Thread to other location your program will compile and run well . I tested it ... by the way , check out your for cicle .. it will print a lot of numbers as Mr. Friedman-Hill said ..