473,671 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

toGet Alive Thread Counts


Hi Guys

How to Get the alive Thread Count.

Sample code :

using System;
using System.Threadin g;

namespace threadSample

{

/// <summary>

/// Summary description for ThreadsCollecti on.

/// </summary>

public class ThreadsCollecti on
{
private Thread testThread;
public ThreadsCollecti on()

{

//

// TODO: Add constructor logic here

//

}

static void Main(string[] args)
{
s.threadsStart( );
Console.WriteLi ne(s.testThread .Name.ToString( ));
}

private void threadsStart()

{

for(int i=0;i<3;i++)

{

testThread = new Thread(new ThreadStart(thi s.threadWorker) );

testThread.Name = "Prabharkan " + i;

this.testThread .Start();

}

}

private void threadWorker()

{

while(true)

{

}

}

}

Now I want to get total number thread running with name

Pls help me to find out a way

(Without dumpping all the started threads in arraylist...)
--

Thanx
Gopal Prabhakaran

--
"Sucess Comes To Those Who Dare To Dream"

Thanx
Gopal Prabhakaran
Nov 15 '05 #1
4 1937
Gopal,

I am not quite sure what you mean. You say you want to get all of the
running threads with the same, but with the same what?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Gopal Prabhakaran" <pr*******@take scm.com> wrote in message
news:%2******** **********@tk2m sftngp13.phx.gb l...

Hi Guys

How to Get the alive Thread Count.

Sample code :

using System;
using System.Threadin g;

namespace threadSample

{

/// <summary>

/// Summary description for ThreadsCollecti on.

/// </summary>

public class ThreadsCollecti on
{
private Thread testThread;
public ThreadsCollecti on()

{

//

// TODO: Add constructor logic here

//

}

static void Main(string[] args)
{
s.threadsStart( );
Console.WriteLi ne(s.testThread .Name.ToString( ));
}

private void threadsStart()

{

for(int i=0;i<3;i++)

{

testThread = new Thread(new ThreadStart(thi s.threadWorker) );

testThread.Name = "Prabharkan " + i;

this.testThread .Start();

}

}

private void threadWorker()

{

while(true)

{

}

}

}

Now I want to get total number thread running with name

Pls help me to find out a way

(Without dumpping all the started threads in arraylist...)
--

Thanx
Gopal Prabhakaran

--
"Sucess Comes To Those Who Dare To Dream"

Thanx
Gopal Prabhakaran

Nov 15 '05 #2
Dear Nicholas Paldino

I have created 5 threads with unique names,

I want the know the status of the threads created by me

Is there any ThreadCollectio n...???

Thnax
Prabharkan.G

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:uO******** ******@TK2MSFTN GP09.phx.gbl...
Gopal,

I am not quite sure what you mean. You say you want to get all of the
running threads with the same, but with the same what?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Gopal Prabhakaran" <pr*******@take scm.com> wrote in message
news:%2******** **********@tk2m sftngp13.phx.gb l...

Hi Guys

How to Get the alive Thread Count.

Sample code :

using System;
using System.Threadin g;

namespace threadSample

{

/// <summary>

/// Summary description for ThreadsCollecti on.

/// </summary>

public class ThreadsCollecti on
{
private Thread testThread;
public ThreadsCollecti on()

{

//

// TODO: Add constructor logic here

//

}

static void Main(string[] args)
{
s.threadsStart( );
Console.WriteLi ne(s.testThread .Name.ToString( ));
}

private void threadsStart()

{

for(int i=0;i<3;i++)

{

testThread = new Thread(new ThreadStart(thi s.threadWorker) );

testThread.Name = "Prabharkan " + i;

this.testThread .Start();

}

}

private void threadWorker()

{

while(true)

{

}

}

}

Now I want to get total number thread running with name

Pls help me to find out a way

(Without dumpping all the started threads in arraylist...)
--

Thanx
Gopal Prabhakaran

--
"Sucess Comes To Those Who Dare To Dream"

Thanx
Gopal Prabhakaran


Nov 15 '05 #3
Gopal,

There is not. If you created the threads, and want to keep track of
them, then you will have to do it yourself. The easiest way to do this is
to have a static method that you use to create your threads and then have a
property that is exposed which will give you the details about the threads
created through that method.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Gopal Prabhakaran" <pr*******@take scm.com> wrote in message
news:en******** ********@TK2MSF TNGP10.phx.gbl. ..
Dear Nicholas Paldino

I have created 5 threads with unique names,

I want the know the status of the threads created by me

Is there any ThreadCollectio n...???

Thnax
Prabharkan.G

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:uO******** ******@TK2MSFTN GP09.phx.gbl...
Gopal,

I am not quite sure what you mean. You say you want to get all of the running threads with the same, but with the same what?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Gopal Prabhakaran" <pr*******@take scm.com> wrote in message
news:%2******** **********@tk2m sftngp13.phx.gb l...

Hi Guys

How to Get the alive Thread Count.

Sample code :

using System;
using System.Threadin g;

namespace threadSample

{

/// <summary>

/// Summary description for ThreadsCollecti on.

/// </summary>

public class ThreadsCollecti on
{
private Thread testThread;
public ThreadsCollecti on()

{

//

// TODO: Add constructor logic here

//

}

static void Main(string[] args)
{
s.threadsStart( );
Console.WriteLi ne(s.testThread .Name.ToString( ));
}

private void threadsStart()

{

for(int i=0;i<3;i++)

{

testThread = new Thread(new ThreadStart(thi s.threadWorker) );

testThread.Name = "Prabharkan " + i;

this.testThread .Start();

}

}

private void threadWorker()

{

while(true)

{

}

}

}

Now I want to get total number thread running with name

Pls help me to find out a way

(Without dumpping all the started threads in arraylist...)
--

Thanx
Gopal Prabhakaran

--
"Sucess Comes To Those Who Dare To Dream"

Thanx
Gopal Prabhakaran



Nov 15 '05 #4
Dear Nicholas Paldino

Thanx for ur Timing Help ,Thanx a Lot....

Can u Pls tell me about - What is ProcessThreadCo llection?

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:O0******** ******@TK2MSFTN GP11.phx.gbl...
Gopal,

There is not. If you created the threads, and want to keep track of
them, then you will have to do it yourself. The easiest way to do this is
to have a static method that you use to create your threads and then have a property that is exposed which will give you the details about the threads
created through that method.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Gopal Prabhakaran" <pr*******@take scm.com> wrote in message
news:en******** ********@TK2MSF TNGP10.phx.gbl. ..
Dear Nicholas Paldino

I have created 5 threads with unique names,

I want the know the status of the threads created by me

Is there any ThreadCollectio n...???

Thnax
Prabharkan.G

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote

in
message news:uO******** ******@TK2MSFTN GP09.phx.gbl...
Gopal,

I am not quite sure what you mean. You say you want to get all of the running threads with the same, but with the same what?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Gopal Prabhakaran" <pr*******@take scm.com> wrote in message
news:%2******** **********@tk2m sftngp13.phx.gb l...
>
> Hi Guys
>
> How to Get the alive Thread Count.
>
> Sample code :
>
> using System;
> using System.Threadin g;
>
> namespace threadSample
>
> {
>
> /// <summary>
>
> /// Summary description for ThreadsCollecti on.
>
> /// </summary>
>
> public class ThreadsCollecti on
> {
> private Thread testThread;
> public ThreadsCollecti on()
>
> {
>
> //
>
> // TODO: Add constructor logic here
>
> //
>
> }
>
> static void Main(string[] args)
> {
> s.threadsStart( );
> Console.WriteLi ne(s.testThread .Name.ToString( ));
> }
>
> private void threadsStart()
>
> {
>
> for(int i=0;i<3;i++)
>
> {
>
> testThread = new Thread(new ThreadStart(thi s.threadWorker) );
>
> testThread.Name = "Prabharkan " + i;
>
> this.testThread .Start();
>
> }
>
> }
>
> private void threadWorker()
>
> {
>
> while(true)
>
> {
>
> }
>
> }
>
> }
>
> Now I want to get total number thread running with name
>
> Pls help me to find out a way
>
> (Without dumpping all the started threads in arraylist...)
>
>
> --
>
> Thanx
> Gopal Prabhakaran
>
> --
> "Sucess Comes To Those Who Dare To Dream"
>
> Thanx
> Gopal Prabhakaran
>
>



Nov 15 '05 #5

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

Similar topics

7
7864
by: sayoyo | last post by:
Hi, Is there some way that we can reuse a thread by replacing the runnable object of the thread? like a thread is not "alive" anymore, then we remove the runnable object(is it possible????) and then run it again. Thanks you very much Sayoyo
1
4475
by: David | last post by:
This is called "evil hack problem" because my problems are due to me trying to do an evil hack. Please don't judge me, just believe that there are reasons for what I'm trying to do :-) I've got a problem with BaseHTTPServer. I am trying to keep a connection alive so that I can send data down it. At the moment, I have subclassed BaseHTTPRequestHandler like this: def do_POST(self):
2
4488
by: Johan W | last post by:
Hi! I want to check if a thread is still alive or if it has been terminated. I can't find a function call that handles that.. Do you have a simple answer? Thank's, Johan
4
5428
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the server. Data is sent and received over these connections using the asynchronous model. The server is currently in beta testing. Sporadically over the course of the day, I'll observe the thread count on the process (via perfmon) start climbing....
2
7292
by: David Rasmussen | last post by:
Someone once asked about this an got no answer: http://groups.google.dk/group/comp.lang.python/browse_frm/thread/c3cc0b8d7e9cbc2/ff11efce3b1776cf?lnk=st&q=python+http+%22keep+alive%22&rnum=84&hl=da#ff11efce3b1776cf Maybe I am luckier :) Does anyone know how to do Keep-Alive with urllib2, that is, how to get a persistent HTTP connection, instead of a new connection being opened for every request?
5
1553
by: Galen Somerville | last post by:
Tooo many examples. I'm confused. VB6 ActiveX.dll with no windows or controls. Interfaces with a device that returns an x size byte array every x milliseconds for x counts. Sends a message to VB2005 main thread on each count. VB2005 has to start the thread and set several variables in the thread before loop starts. VB2005 then has to respond to messages and draw on screen until last count
9
1853
by: cgwalters | last post by:
Hi, I've recently been working on an application which does quite a bit of searching through large data structures and string matching, and I was thinking that it would help to put some of this CPU-intensive work in another thread, but of course this won't work because of Python's GIL. There's a lot of past discussion on this, and I want to bring it up again because with the work on Python 3000, I think it is worth trying
7
7219
by: mail747097 | last post by:
I would like to keep IIS alive on my web site and prevent Application_End from occuring in global.asax. Any ideas?
3
5303
by: RossGK | last post by:
I'm a newbie to python threads, and playing with some simple client server stuff and lots of print statements. My server thread launched with self.worker = WorkerThread(self) completes an interaction and then if I check on it's status with print "Status:", self.worker I get Status none A client thread behaves differently. Launched as
0
8390
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8909
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8596
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7428
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1801
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.