Tn Sharma

Greenhorn
+ Follow
since Jan 01, 2017
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
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tn Sharma

I have problem in creating oracle account.
What to fill in following Fields of oracle.com create account page
1. Job Title
3. Work Phone
2. Company Name
As i am student i dont have any job title or company name
The Iteration speed of HashSet is than LinkedHashSet. but Insertion Deletion speed may be different.
ArrayList has faster ITERATION speed than LinkedList.

Please Give me a chart or something that defines difference between speeds of all Collection in terms of Both Insertion Deletion speed and Iteration Speed.

Henry Wong wrote:

Tn Sharma wrote:
And what if somehow notify() is called before wait() .then waiting will infinite?



Who is calling wait()? Who is calling notify()? There are multiple use-cases in context with this topic, so, which one do you mean?

Anyway...

In the case of your original example (ie. your thread calling wait(), and the clean up code for the thread calling notifyAll()). ... It is not possible for your thread to call wait() after the clean up code for your thread to call notifyAll(). As long as your thread is running, the environment can't clean up after it.

In the case the core library implementation of the join() method (ie. the thread that called join() calling wait(), and the clean up code for the thread calling notifyAll()). ... It is not possible for wait() to be called by join() after the clean up call. The implementation of join() does not do a blind wait. It will check to confirm that the thread is still alive before calling wait().

In the general case (ie. general question -- and not related to this topic). ... Notifications that are sent, when there are no threads waiting for it, are simply discarded.

Henry




Please observe this code
As main thread is calling wait();
and run() method on thread a is calling notify();

But as per code
main is sleeping for 5 seconds while notify() from thread a is called before 5 seconds completed .
After 5 seconds main() will call wait() and there will no notify() or notifyAll() is there.

So this main() will infinitely waiting ( tested by me)

Please differentiate the behavior of this code with original code

Henry Wong wrote:

Tn Sharma wrote:
notify() is not called anywhere BUT waiting Thread is waking up and printing value of a
why it is happening here.



You are conflicting with the core library. Thread class instances are used internally to implement the join() mechanism. Threads that call the join() method will wait() on the Thread instance. And when a thread terminates, it will send a notification (all) on the Thread instance.

Henry



And what if somehow notify() is called before wait() .then waiting will infinite?



notify() is not called anywhere BUT waiting Thread is waking up and printing value of a
why it is happening here.
I come to about Concurrent Collections i.e ConcurrentHashMap today but i never heard about it in any book( including Kathy sierra and Bert bates )or mock exam .

so my question:-
Is Concurrent Collections topic of Ocpjp 6 exam?