Javamex

Java discussion forum to accompany the Javamex web site.

Pallav Shyam's Discussions

lock.lock v/s synchronized

Started this discussion. Last reply by Pallav Shyam Apr 12, 2012. 2 Replies

The thread calling synchronzed(obj) acquires and owns that objects monitor till it releases it. Does lock.lock also behaves in a similar fashion. I tried calling lock.wait() after lock.lock() using…Continue

notify vs notifyall

Started this discussion. Last reply by happy goofy Apr 11, 2012. 6 Replies

Queue.java Attached is a file…Continue

Tags: notifyAll, notify

Gifts Received

Gift

Pallav Shyam has not received any gifts yet

Give a Gift

 

Pallav Shyam's Page

Latest Activity

Pallav Shyam replied to Pallav Shyam's discussion lock.lock v/s synchronized
"Hi Neil, Thanks for the quick reply. Maybe I was not very explicit in my message. I am made to understand that lock.lock behaves exactly the same as synchronized on the lock object. which means if synchronized acquires the object monitor, so does…"
Apr 12, 2012
Neil Coffey replied to Pallav Shyam's discussion lock.lock v/s synchronized
"Welcome to a slightly confusing feature of Locks. If you use one of the explicit Lock classes such as ReentrantLock, then the method you call is called await()-- notice the "a" at the beginning-- rather than the wait() method (which still…"
Apr 12, 2012
Pallav Shyam posted a discussion

lock.lock v/s synchronized

The thread calling synchronzed(obj) acquires and owns that objects monitor till it releases it. Does lock.lock also behaves in a similar fashion. I tried calling lock.wait() after lock.lock() using an instance of ReentrantLock and the code gave me IllegalMonitorStateException.See More
Apr 12, 2012
Pallav Shyam liked Pallav Shyam's discussion notify vs notifyall
Apr 12, 2012
happy goofy replied to Pallav Shyam's discussion notify vs notifyall
"I ran this in Solaris. When the waiting dead lock happens, press ctl+\.  (SIGQUIT, 3).  On Windows, try ctl + break. This problem may result if the program creates say 5 producers and 1 consumer, and each can wake up just one other thread,…"
Apr 11, 2012
Pallav Shyam replied to Pallav Shyam's discussion notify vs notifyall
"Hi Goofy, Good explaination. This is certainly not the deadlock scenario we generally talk about.  By the way, how did you produce the thread trace which shows very clearly the state of each thread. Thanks, Pallav"
Apr 11, 2012
happy goofy replied to Pallav Shyam's discussion notify vs notifyall
"This program creates 1 producer thread and 5 consumer threads, all synchronized on an Object of type ArrayList. With notify (not notifyAll) executed by each thread , there will be,of course, at most one thread running (RUNNABLE), at most…"
Apr 10, 2012
happy goofy replied to Pallav Shyam's discussion notify vs notifyall
"I replaced reply for replyAll as indicated in the source. I kept runnning it for some times. Yes, I saw the deadlock. Anyone got an insight?"
Mar 20, 2012
Pallav Shyam replied to Pallav Shyam's discussion notify vs notifyall
"package com.msci.dm.timepass; import java.util.ArrayList; import java.util.List; public class Queue { private List queue = new ArrayList(); private final int MAX_SIZE = 1; public void push(String s){…"
Aug 24, 2011
Neil Coffey replied to Pallav Shyam's discussion notify vs notifyall
"I couldn't see the attached file -- perhaps you can just paste the code in?"
Aug 24, 2011
Pallav Shyam posted a discussion

notify vs notifyall

Queue.java Attached is a file containing a simple producer consumer scenario that I wrote.Changing queue.notifyAll() to queue.notify() in the push method creates a deadlock.Not sure why? Is there any significant difference between notify and notifyAll which I am missing?  Thanks,PallavSee More
Aug 24, 2011
Pallav Shyam is now a member of Javamex
Aug 24, 2011

Profile Information

What other languages do you use apart from Java?
Other

Comment Wall

You need to be a member of Javamex to add comments!

Join Javamex

  • No comments yet!
 
 
 

© 2017   Created by Neil Coffey.   Powered by

Badges  |  Report an Issue  |  Terms of Service