?
Solved

Mulithreading in c++

Posted on 2003-03-08
7
Medium Priority
?
362 Views
Last Modified: 2010-04-01
How do you implement multithreading in c++? What are the basic steps?
0
Comment
Question by:vinay_13
7 Comments
 
LVL 8

Expert Comment

by:mnashadka
ID: 8094184
Multithreading is platform-dependent, so you can't give any one answer without knowing the operating system and compiler.  However, there are some nice thread-supporting classes in the boost libraries (at www.boost.org) that you can use to make threading the same across platforms.
0
 
LVL 1

Expert Comment

by:MatrixDud
ID: 8095239
It all depends. If you're using MFC you can use AFXBeginThread which is a simple thread class. It's not too robust but it's adequate for most simple tasks.

Here's a link to that:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_afxbeginthread.asp

There's also CWinThread or the Win32 Call CreateThread. Here's an overall good link with examples for the bunch.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnw98bk/html/makingmodifyingthreads.asp

You might also want to user CCriticalSection in places if your multiple threads might access the same data or resources. A good example where threads can make a mess of things is when they write data to files. There are better ThreadLocking classes you might consider instead, like CSingleLock or CMutex.
0
 
LVL 2

Expert Comment

by:bkrahmer
ID: 8095378
The first step to properly using multiple threads is to get pretty deep into some reading.  Threads are probably the most powerful tools that you can be given to shoot yourself in the foot.  Jumping into them without understanding the thread lifecycle, contention,  synchronization and the like will probably be very painful.  I'm all for using them, but be sure you play with them using small examples and work your way up.

brian
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:vinay_13
ID: 8096912
Dear mnashadka, I'm working in DOS with Turbo c++ compiler.
i also have windows but i need this to work in case only dos is available
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8097181
DOS is a single-tasking O/S.  The short answer is "It can't be done"
-- Dan
0
 
LVL 5

Expert Comment

by:Kocil
ID: 8100003
Yes it can be done, I did it before with Borland C++ 3.1.
But you need to write, or search, a special routines to do that.

0
 
LVL 5

Accepted Solution

by:
Kocil earned 200 total points
ID: 8100030
I was using my own library, but I wrote the documentation on my native language so it may hard for you to use.
However, I found this on top list from google
search: +DOS +multithreading +library
http://www.simtel.net/pub/pd/42681.html
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question