473,382 Members | 1,437 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,382 software developers and data experts.

Easy Threading Question.

I was wondering if any one could help me out with a threading question.

Im developing an app which starts a thread, which in turn starts 4 of its
own threads.

If I call 'sleep' on the initial thread, will this cause all of its children
to sleep also?

Thanks in advance.
Nov 20 '05 #1
6 1112
Hi Matt,

I think the answer is NO. Even the thread A is sleepting the other threads
it creates will not sleep and will continue running.
In windows platform the thread is a kernel object too, the OS allots the
CPU time based on threads, that is to say the OS schedule algorithm will
decide which thread will own CPU time for an assignment unit. Thread A is
sleeping will not impact thread B created in Thread A to sleep too.

Imports System.Threading
Module Module1
Dim bFlag As Boolean = True
Public Sub ThreadProc()
While bFlag
Console.WriteLine(Threading.Thread.CurrentThread.N ame + "is
running...")
End While
End Sub
Public Sub StrartupThreadProc()
For i As Integer = 0 To 4
Dim td As New Thread(AddressOf ThreadProc)
td.Name = "Sub Thread" + i.ToString()
td.Start()
Next
Thread.Sleep(5000)
bFlag = False
End Sub
Sub Main()
Dim thread1 As New Thread(AddressOf StrartupThreadProc)
thread1.Name = "First Thread"
thread1.Start()
'wait for thread1 exit
thread1.Join()
End Sub
End Module

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #2
> I was wondering if any one could help me out with a threading question.

Im developing an app which starts a thread, which in turn starts 4 of its
own threads.

If I call 'sleep' on the initial thread, will this cause all of its children to sleep also?

Thanks in advance.

I think the philosophy is wrong ... who get up the thread parent ?
The sleep must not be on it,but the sleep must be called on its children ...

you can check the thread state for wait ....

I Think =o)
--
Ciao

::M:a:r:c:o:::P:e:s:c:e::
it***************@hotmail.com
per contatti PVT elinimare NOSPAM
Nov 20 '05 #3
No

/claes

"Matt Long" <So******@NOSPAM.Diskcovery.com.au> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
I was wondering if any one could help me out with a threading question.

Im developing an app which starts a thread, which in turn starts 4 of its
own threads.

If I call 'sleep' on the initial thread, will this cause all of its children to sleep also?

Thanks in advance.

Nov 20 '05 #4
I only wish your philosphy were true in real life, my children will stay
awake regardless of my state of conciousness

:-)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"::P:e:s:c:e:::M:a:r:c:o::" <it***************@hotmail.com> wrote in message
news:u7**************@TK2MSFTNGP09.phx.gbl...
I was wondering if any one could help me out with a threading question.

Im developing an app which starts a thread, which in turn starts 4 of its own threads.

If I call 'sleep' on the initial thread, will this cause all of its children
to sleep also?

Thanks in advance.

I think the philosophy is wrong ... who get up the thread parent ?
The sleep must not be on it,but the sleep must be called on its children

....
you can check the thread state for wait ....

I Think =o)
--
Ciao

::M:a:r:c:o:::P:e:s:c:e::
it***************@hotmail.com
per contatti PVT elinimare NOSPAM

Nov 20 '05 #5
LOL!!!

[yawns and tells 3 year old to go to bed..... again....]
__________________________________________________ __
The Grim Reaper

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:Of*************@tk2msftngp13.phx.gbl...
I only wish your philosphy were true in real life, my children will stay
awake regardless of my state of conciousness

:-)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"::P:e:s:c:e:::M:a:r:c:o::" <it***************@hotmail.com> wrote in message news:u7**************@TK2MSFTNGP09.phx.gbl...
I was wondering if any one could help me out with a threading question.
Im developing an app which starts a thread, which in turn starts 4 of its own threads.

If I call 'sleep' on the initial thread, will this cause all of its

children
to sleep also?

Thanks in advance.

I think the philosophy is wrong ... who get up the thread parent ?
The sleep must not be on it,but the sleep must be called on its children

...

you can check the thread state for wait ....

I Think =o)
--
Ciao

::M:a:r:c:o:::P:e:s:c:e::
it***************@hotmail.com
per contatti PVT elinimare NOSPAM


Nov 20 '05 #6
Thankyou Peter, that was a great help.

""Peter Huang"" wrote:
Hi Matt,

I think the answer is NO. Even the thread A is sleepting the other threads
it creates will not sleep and will continue running.
In windows platform the thread is a kernel object too, the OS allots the
CPU time based on threads, that is to say the OS schedule algorithm will
decide which thread will own CPU time for an assignment unit. Thread A is
sleeping will not impact thread B created in Thread A to sleep too.

Imports System.Threading
Module Module1
Dim bFlag As Boolean = True
Public Sub ThreadProc()
While bFlag
Console.WriteLine(Threading.Thread.CurrentThread.N ame + "is
running...")
End While
End Sub
Public Sub StrartupThreadProc()
For i As Integer = 0 To 4
Dim td As New Thread(AddressOf ThreadProc)
td.Name = "Sub Thread" + i.ToString()
td.Start()
Next
Thread.Sleep(5000)
bFlag = False
End Sub
Sub Main()
Dim thread1 As New Thread(AddressOf StrartupThreadProc)
thread1.Name = "First Thread"
thread1.Start()
'wait for thread1 exit
thread1.Join()
End Sub
End Module

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #7

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

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
19
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException....
4
by: Antal Rutz | last post by:
Hi, All! I'm new to threading. I have some design questions: Task: I collect data and store them in an RDBMS (mysql or pgsql) The question is how to do that with threading? The...
6
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service...
7
by: Anthony Nystrom | last post by:
What is the correct way to stop a thread? abort? sleep? Will it start up again... Just curious... If the thread is enabling a form, if the form is disposed is the thread as well? Thanks, ...
4
by: Bob | last post by:
- For cleanup, is it sufficient to set a Thread to Nothing after it's done? - It is OK to pass objects out of the thread? (dumb question maybe but I want to be sure) - What's the best way to...
4
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In...
4
by: Steven | last post by:
I am taking an "advanced" VB.Net course via web at a state university toward an information science degree. This is my second VB class and I am kind of disappointed in it. This week we covered...
19
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.