By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,421 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,421 IT Pros & Developers. It's quick & easy.

Multithread prob.

P: n/a
Hi All:

Is it possible in a class' member function to start a thread calling
another member function in the same class' .....? .i.e

class A
{

void f1(void*)
{
}

void f2()
{
....

startthead(f1); // i tried _beginthread wont work at least...
....
}
}
Thanks.

D.
Jul 9 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
* David:
>
Is it possible in a class' member function to start a thread calling
another member function in the same class
Yes.

Threading is however not yet part of standard C++.
' .....?

Meaningless.

.i.e
Incorrect assumption.

class A
{
void f1(void*)
{
}

void f2()
{
...

startthead(f1); // i tried _beginthread wont work at least...
...
}
}
This code does not compile. See the FAQ on how to post.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 9 '06 #2

P: n/a

David wrote:
Hi All:

Is it possible in a class' member function to start a thread calling
another member function in the same class' .....? .i.e

class A
{

void f1(void*)
{
}

void f2()
{
...

startthead(f1); // i tried _beginthread wont work at least...
...
}
}
Thanks.

D.
Most of the thread libraries expect non-member function pointer. You
can get away by making the function static and passing the _this_ ptr
to it.

Ramneek
www.lazybugz.net

Jul 9 '06 #3

P: n/a
I see. Thanks

D.

"rami" <on***********@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
>
David wrote:
>Hi All:

Is it possible in a class' member function to start a thread calling
another member function in the same class' .....? .i.e

class A
{

void f1(void*)
{
}

void f2()
{
...

startthead(f1); // i tried _beginthread wont work at least...
...
}
}
Thanks.

D.

Most of the thread libraries expect non-member function pointer. You
can get away by making the function static and passing the _this_ ptr
to it.

Ramneek
www.lazybugz.net

Jul 9 '06 #4

P: n/a
Hi,

Try the ACE threading library if you need to use threads in an OO way.
ACE has some neat classes, like ACE_Task which make it quite easy to
use threads in an OO way.

http://www.cs.wustl.edu/~schmidt/ACE.html

Thanks and regards
Sonison James

David wrote:
I see. Thanks

D.

"rami" <on***********@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...

David wrote:
Hi All:

Is it possible in a class' member function to start a thread calling
another member function in the same class' .....? .i.e

class A
{

void f1(void*)
{
}

void f2()
{
...

startthead(f1); // i tried _beginthread wont work at least...
...
}
}
Thanks.

D.
Most of the thread libraries expect non-member function pointer. You
can get away by making the function static and passing the _this_ ptr
to it.

Ramneek
www.lazybugz.net
Jul 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.