PC Review


Reply
Thread Tools Rate Thread

Why use Monitor.Pulse?

 
 
=?Utf-8?B?QmVuIFIu?=
Guest
Posts: n/a
 
      13th Apr 2007
Hi,

I'm new to threading, and am trying to understand monitor.pluse. I get the
general idea, but what does this offer that simply using a semaphore does not
offer? If you have two threads, couldn't you just immediately have one thread
in the ciritical section and have the other try to enter. It will wait until
the lock is handed back, and the lock could continue to be passed back and
forth this way. The off thread will sleep until it's its turn. How is this
different than "pulsing" a thread to a ready queue before handing a lock back?

Thanks..

-Ben
 
Reply With Quote
 
 
 
 
Technics
Guest
Posts: n/a
 
      13th Apr 2007
> I'm new to threading, and am trying to understand monitor.pluse. I get the
> general idea, but what does this offer that simply using a semaphore does not
> offer? If you have two threads, couldn't you just immediately have one thread
> in the ciritical section and have the other try to enter. It will wait until
> the lock is handed back, and the lock could continue to be passed back and
> forth this way. The off thread will sleep until it's its turn. How is this
> different than "pulsing" a thread to a ready queue before handing a lock back?



Technically a monitor is an object that can handle more than ore
resource at a time. Think about what would happen if a thread that is
in its critical region needs a resource locked by another thread's
semaphore and that second thread needs to enter in the critical region
too. This would handle to a deadlock. A monitor should avoid this kind
of problems.

 
Reply With Quote
 
 
 
 
Barry Kelly
Guest
Posts: n/a
 
      13th Apr 2007
Ben R. wrote:

> I'm new to threading, and am trying to understand monitor.pluse. I get the
> general idea, but what does this offer that simply using a semaphore does not
> offer?


A semaphore requires that you allocate a semaphore. Every object
logically has a monitor associated with it.

-- Barry

--
http://barrkel.blogspot.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger Microsoft ASP .NET 4 21st Dec 2006 02:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger Microsoft ASP .NET 2 2nd Dec 2006 04:46 PM
HELL Reinstalling XP WHY WHY WHY ??? Paul M Windows XP Help 9 27th Feb 2005 09:49 AM
Why?Why?Why?Why? Doug Microsoft Word New Users 4 8th Jun 2004 05:28 PM
*****Can't Hibernate... Why? Why? Why?***** Papa Smurf Windows XP General 2 3rd Jan 2004 12:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:11 PM.