Re: is it possible to switch between threads manually.
On 2007-10-01 12:21, firstname.lastname@example.org wrote:
First, the current C++ standard has no knowledge about threads, so your
question is off topic, perhaps comp.programming.threads is a better
suited group for your questions.
I have program which utilizes 5 threads to complete the process.
when the application starts running, it randomly switches between
threads to complete the process as expected.
The whole idea with threads is that more than one of them can execute
concurrently, so unless you only have a single-core CPU without hyper-
threading capabilities (or similar) your application's thread should be
My question is, when the process is running, can i interrupt it
manually and switch between threads?
for example, the application is running, now when i interrupted, the
applications thread is on thread3.
Now from thread3 can i switch to thread5 and continue with execution?
if yes, is there any difference in what operating system does and what
It depends on your threading library, but I have never heard of one that
allows that kind of manipulation, not can I come up with a reason to do so.
if yes, is there a chance of getting coredump?
if yes, what happens to the stacks of other threads?
Each thread should have its own stack so not much I would imagine.
if yes, what happens to the thread which was interrupted manually( in
this case what happens to thread3)?
It stops running?
will thread3 starts from where it was stopped? or will it starts from
where it has been ordered by OS?
If you find a library that allows you to do such a thing, then it would
probably continue from where it was stopped.
Appreciate your views and comments on this topic.
My views are that it is a weird idea with little practical applications.
If you want to allow such behaviour then write the application to allow
it, I would imagine that for some applications arbitrary stopping a
thread in the middle of execution could have disastrous consequences.