?
Solved

Mulithreading in c++

Posted on 2003-03-08
7
Medium Priority
?
359 Views
Last Modified: 2010-04-01
How do you implement multithreading in c++? What are the basic steps?
0
Comment
Question by:vinay_13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

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!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

764 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