Archived

This topic is now archived and is closed to further replies.

MrChris

C++ Threads for a Java programmer.

Recommended Posts

Ok, Heres the deal, I''ve been writing Java for as long as I can remember and have become fairly competant in it''s threading model. Now I''m trying to learn C++ and whilst most of the cross over has been easy, the thread model seems radically different. What I''d like to do: Have an object ''ServerThread'' that will spawn off of the main program and wait for events (Just sit in a while loop basically checking the event cue). There being no direct crossovers to ''Runnable'' or ''Thread'' to use in C++ I''m looking for a decent tutorial or explanation on how to do this or something similar. I''ve found plenty of tutorials dealing with Java for C++ programmers but nothing the other way around. Anyone got any ideas? Cheers, MrChris

Share this post


Link to post
Share on other sites
Thanks for that.

I tried to leave it deliberately ambiguous as I''m wanting to try and maintain a semblance of platform independance. If it comes to a crunch though Windows is probably the most common target platform.

Coming from Java I want to be as generic as possible while maintaining efficiency.

A lot of people mention SDL for cross platform work, is that worth looking into maybe?

But if you have some windows examples I''d be grateful as well.

Share this post


Link to post
Share on other sites
It's pretty easy to write a C++ class that's like the Java Thread class using the Win32 SDK. Managing threads is fairly easy with Win32. Look in the SDK documentation, and there're good tutorials.

Edit: Typo

[edited by - zaniwhoop2 on October 11, 2003 1:39:21 AM]

Share this post


Link to post
Share on other sites