* Pthread consume 100% CPU
@ 2002-08-19 14:20 Theewara Vorakosit
0 siblings, 0 replies; only message in thread
From: Theewara Vorakosit @ 2002-08-19 14:20 UTC (permalink / raw)
To: linux-c-programming
Dear All,
I developer multithread programming on linux using pthread. I use C++
language. I implement my thread as a class. Here is my class:
static void *thread_func(void *rv)
{
((Thread *) rv)->run();
return NULL;
}
int Thread::start(void)
{
int retval;
sigfillset(&newset);
pthread_sigmask(SIG_BLOCK, &newset, &oldset);
pthread_attr_init(&attr);
retval = pthread_create(&(this->pt), NULL, thread_func, this);
pthread_sigmask(SIG_UNBLOCK, &newset, &oldset);
return retval;
}
int Thread::join(void)
{
int retval;
pdebugl();
retval = pthread_join(this->pt, NULL);
pdebugl();
return retval;
}
To create thread, inherited this class, new it and call start method. After
call pthread_create, there are 3 processes of my program, right? I call
method join, and exit from my main. My program exits normally. However,
there is thread process still running at 100% reported by top. I also get
command prompt from my shell. Would you please tell what cause this problem?
Thanks,
Theewara
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-08-19 14:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-19 14:20 Pthread consume 100% CPU Theewara Vorakosit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).