473,320 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1346
* 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: haptiK | last post by:
Hello, can i use php to multithread mail() or something similar? in my company i need to send multiple copies of email to a few hundred ppl affilated and on my list. instead of calling mail...
4
by: dbmethods | last post by:
Could someone give a hint on how to do multithread programming with PHP scripting here? Thanks
0
by: Alice | last post by:
Hello I have four multithread windows applications(vb.net) interacting and running on the same machine(windows 2000 with .net framework 1.0). All of them start a new thread each time Filewatcher's...
0
by: r_obert | last post by:
Hello, I'm trying to create a worker thread for my VC++ program, and was wondering whether I should be linking with the Multithread /MT or Multithread DLL /MD option? I'm not quite sure, in...
3
by: QQ | last post by:
I am new here and got lost on a multithread C++ system source codes Thanks a lot!
4
by: zbcong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting for a...
2
by: zhebincong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting...
0
by: fred | last post by:
I need some help in trying to understand how to make myCollection (inherited from CollectionBase) multithread safe. Taking my implementation of the Add Sub and a readonly property Item. Public...
6
by: jmartin | last post by:
Hi, I have made a multithread version of a program (load a file into database), and with two processors I get the double of time in the multithread than in the process (unithread) version. I...
2
by: tikcireviva | last post by:
Hi Guys, I've done a mulithread queue implementation on stl<queue>, my developement environment is on VC6 as well as FC3. Let's talks about the win32 side. The suspected memory leak is find...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.