Meaningless Drivel is fun!
The moose likes Java in General and the fly likes One questions maybe not related to java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "One questions maybe not related to java" Watch "One questions maybe not related to java" New topic

One questions maybe not related to java

walter wang
Ranch Hand

Joined: Jun 02, 2001
Posts: 159
Dear All
I know how to implement multi thread in java
but how to do it in c and c++?
could any one show me a piece of sample codes?

public class Walter { public boolean is_Working_Now (boolean is_boss_Coming) { return is_boss_Coming; }
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

One reason Java incorporates multi-threading into its platform is to avoid the detail and incompatibilities of thread systems on different OS platforms.
Any example will therefore be specific to an operating system or a family of closely related ones.
That said, in C/C++ they're written the same way. A C/C++ thread points to a starter function which in turns has all the code. One or more flag values are used to indicate certain behavior for the thread (priority, service or utility thread, etc.).
Here's an pseudo-example stolen from this book. It uses threading to load images from files into memory:

Not hard to see why people like what Java promises: a cleaner way to get to a complex but powerful programming technique. With a little thought, I could probably write the complete example in Java in fewer lines, and compile it on the first or second go.

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
I agree. Here's the link:
subject: One questions maybe not related to java
It's not a secret anymore!