aspose file tools*
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
Author

One questions maybe not related to java

walter wang
Ranch Hand

Joined: Jun 02, 2001
Posts: 148
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?
thx.


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

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
 
jQuery in Action, 2nd edition
 
subject: One questions maybe not related to java
 
Similar Threads
How to find local systems free space?
copying files from src to dstn directory
Native methods or running c++ code
Calling C program from Multiple Java Programs
integrating Java with #C, having issues