473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

.NET Multithreading question

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)?

--
Ioannis Vranos
Nov 17 '05 #1
4 998
Ioannis Vranos wrote:
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?
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.

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #2
Doug Harrison [MVP] wrote:
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.

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

--
Ioannis Vranos
Nov 17 '05 #3
Ioannis Vranos wrote:
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.

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #4
Doug Harrison [MVP] wrote:
Ioannis Vranos wrote:

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.

--
Ioannis Vranos
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jean-Yves Nief | last post by:
hello, I have written a script which is performing some tasks in multithreading mode: the main thread is opening a connection to a distant server and all the threads that I start will have to...
1
by: dixp | last post by:
I'm new to writing multithreaded apps and I have a design question. I have a winforms app and a class which has a method that does processing which is time intensive. I want the user to be able...
0
by: GianGuz | last post by:
In the following example Global is able to create and manage access to objects of any kind (even in a multithreading environment) with and index value attached to. So a Global<0, string> is a...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
10
by: Marek | last post by:
Hi, I am analyzing Duwamish7 source code boundled with Visual Studio .NET 2003. Could anoybody explain why the Monitor.Enter and Monitor.Exit block is used inside a static constructor? The code...
2
by: Rich | last post by:
Hello, I have set up a multithreading routine in a Test VB.net proj, and it appears to be working OK in debug mode and I am not using synchronization. Multithreading is a new thing for me, and...
2
by: Multithreading problem in vb.net | last post by:
Greetings, I am new to multithreading and I am trying to implement it in my app. This application is distributed application which needs to refresh every say 5 secs to show some activities in...
6
by: MeowCow | last post by:
I will try and make my question with out being too long winded. I have been doing a lot of reading on how to do multithreading and I have implemented the code from the following example on...
7
by: Ray | last post by:
Hello, Greetings! I'm looking for a solid C++ multithreading book. Can you recommend one? I don't think I've seen a multithreading C++ book that everybody thinks is good (like Effective C++ or...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.