[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Thread::detach() call doesn't return
From: |
Nacho de los Ríos Tormo |
Subject: |
Re: Thread::detach() call doesn't return |
Date: |
Mon, 31 Mar 2003 17:59:57 +0200 |
User-agent: |
KMail/1.4.3 |
Hello,
After a week with no replies, I must face the fact that either nobody knows an
answer or, more likely, nobody made could make heads nor tails of a poor (and
too long) explanation.
My problem is: sometimes, in my Thread subclasses, the moment I call detach()
(whether from the constructor or at a later point), the current thread is
permanently lost.
This only happens when I link in some older code we've got, even if this older
code is not called and is left dead.
This older code is some older single-thread code that runs fine if:
a)compiled as a single thread program
b)its original main() function is called from the run()
method of a Thread subclass (though in this case control
won't return to the calling thread).
In the example below, when linking the other code, message "MESSAGE" would
never get printed; however, not linking that other code, "MESSAGE" would be
printed. In both cases, I would get periodic "Rollover!" messages.
What so toxic might be lurking in the old code that could make this happen?
Thanks for your attention,
Nacho de los Rios.
----------------------------------------------------
class MyClass1 : public Thread
{
void run(void)
{
int i = 0;
while(true)
if (++i == 0) cout << "Rollover!" << endl;
};
public:
MyClass1 (void)
{
detach();
}
};
void main(void)
{
MyClass1* p1;
p1 = new MyClass1();
cout << "MESSAGE" << endl;
}