468,456 Members | 1,701 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,456 developers. It's quick & easy.

Multithread prob.

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
4 1195
* 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

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
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
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.

Similar topics

12 posts views Thread by haptiK | last post: by
4 posts views Thread by dbmethods | last post: by
reply views Thread by Alice | last post: by
reply views Thread by r_obert | last post: by
2 posts views Thread by zhebincong | last post: by
6 posts views Thread by jmartin | last post: by
1 post views Thread by subhajit12345 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.