Thread within Thread

I have a main thread (e.g. MainThread) that runs through a list of files to FTP/Copy/Email somewhere. I then have another thread that is called from within MainThread to send the files one at a time (e.g. SubThread).

My issue is this: when the SubThread thread is running (from within the first thread), how come MainThread.Running = False? Is MainThread not really running?

I have a workaround by using: not MainThread.NotRunning

Is MainThread Paused or Sleeping? What is the actual state?

A typical use of threads.

Thread1:		Thread2:
do1()			do2()
do1()			do2()
do1()			do2()
do1()			do2()
do1()			do2()
do1()			do2()
do1()			do2()

What I understand you want:

Thread1:		Thread2:
do1()
do1()
do1()
do1()
			do2()
			do2()
			do2()
			do2()
do1()
do1()
do1()
do1()

Why not? :

Thread1:
do1()
do1()
do1()
do1()
do2()
do2()
do2()
do2()
do1()
do1()
do1()
do1()

For coordinating multiple threads I would use some dedicated flags protected by Critical Sections.
Enter(), Set value, Leave(); Enter(), Read value, Leave().

There seems to be a misconception. Methods can run within a Thread, but Threads run independently of each other no matter where they were initiated from, so one thread does not run “within” another thread, ever.

MainThread jumps between 0 (Running) and 1 (Waiting).

[quote]There seems to be a misconception. Methods can run within a Thread, but Threads run independently of each other no matter where they were initiated from, so one thread does not run “within” another thread, ever.
[/quote]

I agree. But if the MainThread is spinning around internally, waiting for the SubThread to finish, I would have thought it would still be set as MainThread.Running. I will change my code to check if MainThread.Running or MainThread.Waiting then …

Thanks for the comments.

I always use “not NotRunning” as the test. Any other state means the thread is active in some way.