Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 117,284 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 2,316 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Multithread Programming in C++

 
Reply to this topicStart new topic

Multithread Programming in C++

Treasure
post 19 Jul, 2008 - 09:09 PM
Post #1


New D.I.C Head

*
Joined: 19 Jul, 2008
Posts: 5

I am new to multithread programming, can anyone help me with a simple program in C++ with some explanation

This post has been edited by Treasure: 19 Jul, 2008 - 09:11 PM
User is offlineProfile CardPM

Go to the top of the page


skaoth
post 19 Jul, 2008 - 11:42 PM
Post #2


D.I.C Regular

Group Icon
Joined: 7 Nov, 2007
Posts: 333



Thanked 8 times

Dream Kudos: 100
My Contributions


QUOTE(Treasure @ 19 Jul, 2008 - 09:09 PM) *

I am new to multithread programming, can anyone help me with a simple program in C++ with some explanation


It all really depends on the platform you'll be using.
If you are using Microsofts API, I would start here: http://msdn.microsoft.com/en-us/library/kdzttdcb(VS.71).aspx.

There is also pthreads, which is more often used on linux systems A good place to begin is here: https://computing.llnl.gov/tutorials/pthreads/

Lastly there is boost, which is a large set of libraries: I'm not familiar with this particular API, though I do find boost useful. http://www.boost.org/doc/libs/1_35_0/doc/html/thread.html
User is online!Profile CardPM

Go to the top of the page

Treasure
post 20 Jul, 2008 - 10:59 AM
Post #3


New D.I.C Head

*
Joined: 19 Jul, 2008
Posts: 5

Thanks, I am going through the MSDN site you mentioned. The platform I am working on is XP
User is offlineProfile CardPM

Go to the top of the page

Treasure
post 20 Jul, 2008 - 06:52 PM
Post #4


New D.I.C Head

*
Joined: 19 Jul, 2008
Posts: 5

QUOTE(Treasure @ 20 Jul, 2008 - 10:59 AM) *

Thanks, I am going through the MSDN site you mentioned. The platform I am working on is XP




Hi skaoth, I am writing a multithreaded C++ application using Microsoft Visual Studio.NET 2003. I plan to have one thread which will open a command prompt and print 'hello', say n times and in the mean time other thread opens another command prompt which will print 'World' say m times. The main thread will open print 'Hello World' on the command prompt.

I don't know if I can make it work this way, but I am going to try. I will appreciate any help.
User is offlineProfile CardPM

Go to the top of the page

skaoth
post 20 Jul, 2008 - 09:30 PM
Post #5


D.I.C Regular

Group Icon
Joined: 7 Nov, 2007
Posts: 333



Thanked 8 times

Dream Kudos: 100
My Contributions


If I were you I'd try and keep things simple. At this point I wouldn't worry about "opening up a command prompt" for each of the 2 threads. Displaying the output onto 1 command prompt window should be work just fine. Concentrate on getting your threads working first.

Keep things simple until you know the threads do what you want, only then should you increase the complexity.
User is online!Profile CardPM

Go to the top of the page

Treasure
post 21 Jul, 2008 - 07:43 PM
Post #6


New D.I.C Head

*
Joined: 19 Jul, 2008
Posts: 5

QUOTE(skaoth @ 20 Jul, 2008 - 09:30 PM) *

If I were you I'd try and keep things simple. At this point I wouldn't worry about "opening up a command prompt" for each of the 2 threads. Displaying the output onto 1 command prompt window should be work just fine. Concentrate on getting your threads working first.

Keep things simple until you know the threads do what you want, only then should you increase the complexity.


Hi skaoth
You were so right, when I started coding I felt stuck, and so I started with the basics of just trying to get my threads right smile.gif. Thanks.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 10/6/08 10:56PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month