Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2004

Tip: Looking for answers? Try searching our database.

.NET Multithreading question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ioannis Vranos - 13 Oct 2004 00:26 GMT
One .NET question. Lets assume that a thread has the lock on an object
and performs a

Monitor::Pulse(obj);

and with that it returns another thread on this object in the running
state, what happens?

Does the other thread become blocked, and while it is in this blocked
state, does it consume processor time (like an infinite loop for example)?

Signature

Ioannis Vranos

Doug Harrison [MVP] - 13 Oct 2004 01:39 GMT
>One .NET question. Lets assume that a thread has the lock on an object
>and performs a
[quoted text clipped - 3 lines]
>and with that it returns another thread on this object in the running
>state, what happens?

According to the Monitor.Pulse documentation:

"The thread that currently owns the lock on the specified object invokes
this method to signal the next thread in line for the lock. Upon receiving
the pulse, the waiting thread is moved to the ready queue. When the thread
that invoked Pulse releases the lock, the next thread in the ready queue
(which is not necessarily the thread that was pulsed) acquires the lock."

The "other" thread is moved to the ready queue, not set running.

>Does the other thread become blocked, and while it is in this blocked
>state, does it consume processor time (like an infinite loop for example)?

So the thread issuing the Pulse continues to run until it releases the lock,
at which point, the thread at the head of the ready queue for the syncobject
acquires it and is scheduled to run.

Signature

Doug Harrison
Microsoft MVP - Visual C++

Ioannis Vranos - 13 Oct 2004 02:15 GMT
> According to the Monitor.Pulse documentation:
>
[quoted text clipped - 12 lines]
> at which point, the thread at the head of the ready queue for the syncobject
> acquires it and is scheduled to run.

Thanks for the answer. Those threads in the ready queue do not use any
processor time, right?

Signature

Ioannis Vranos

Doug Harrison [MVP] - 13 Oct 2004 02:32 GMT
>Thanks for the answer. Those threads in the ready queue do not use any
>processor time, right?

They're not running, so that's correct. Of course, the OS scheduler spends
some time deciding who gets to run, but that's normally of no concern.

Signature

Doug Harrison
Microsoft MVP - Visual C++

Ioannis Vranos - 13 Oct 2004 02:51 GMT
>>Thanks for the answer. Those threads in the ready queue do not use any
>>processor time, right?
>
> They're not running, so that's correct. Of course, the OS scheduler spends
> some time deciding who gets to run, but that's normally of no concern.

OK, thanks a lot.

Signature

Ioannis Vranos


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.