Sucharitha Lakshmi

Greenhorn
+ Follow
since May 04, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sucharitha Lakshmi

Below is the code I tried:


If I comment the line marked //line1 then both the thread named thread1 and thread2 work as expected(High priority thread runs first then low priority) but with line1 in place, the behavior is not guarenteed.
My doubt is when the current thread is made to sleep, it is out there some where and comes back to runnable state after the time(here 1 sec).
Now, we have both the threads then why doesn't the high priority thread get the chance.

As I know, it is guarenteed that the currently running thread is of high or equal priority than all the available runnable threads.

Can anyone clarify the above behavior?

Thanks in Advance.
Hi

When you say replace with "the code that takes parameter as Employee"
its actually not overriding of equals(). It is overloading.

And when you add objects to set,
In case 1: valid overriding, with Object as parameter, it returns true.So, the Set doesn't allow duplicate insertion.
In case 2: you are not overriding, means the Object class' equals() method is called which returns false because the objects are different(two objects having same employee name). So, both are added to Set.

Regards
Sucharitha.