How do threads in windows work?
Say I wanted to put a method of a class in a thread, is that possible? If so then how.
a.h{text-decoration:none;color:blue;};a.h:hover{text-decoration:underline;background:red;};
Why is it called a hot water heater? Isn't it cold when it goes in the tank?
[email=jtaylor@gtemail.net" class="h]-=CF=-[/email]
Do I look like your F1 key? Search or grep your docs before coming to the board. Searching for "thread" should pull up enough to get you started.
Actually, what you are asking is, how do threads work in C++?
Well, all of the [current] standard thread creation functions (e.g., _beginthread(), CreateThread()) are built around C.
So, if you want to use them for C++ methods, you'd have to do one of two things:
1) Make the C++ method static. This means that the method could not access member variables. A static member function works within the C Thread libraries, because there is no implicit _this_ argument.
2) If you want to run a non-static method in a seperate thread, you'd have to use a much more complex method...I created my own class for this (based on what I had read elsewhere).
Here's the main body of my code...
That should help you with using threads in C++.
Edited by - Dragn on April 23, 2001 9:55:23 PM
Well, all of the [current] standard thread creation functions (e.g., _beginthread(), CreateThread()) are built around C.
So, if you want to use them for C++ methods, you'd have to do one of two things:
1) Make the C++ method static. This means that the method could not access member variables. A static member function works within the C Thread libraries, because there is no implicit _this_ argument.
2) If you want to run a non-static method in a seperate thread, you'd have to use a much more complex method...I created my own class for this (based on what I had read elsewhere).
Here's the main body of my code...
|
That should help you with using threads in C++.
Edited by - Dragn on April 23, 2001 9:55:23 PM
I've got a thread class too. It follows the Java Thread interface, but it's in C++, written for Windows.
www.eecs.ukans.edu/~millew
Questions and comments welcome.
Edited by - WMiller on April 23, 2001 12:42:58 AM
www.eecs.ukans.edu/~millew
Questions and comments welcome.
Edited by - WMiller on April 23, 2001 12:42:58 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement