how is concurrent programming accomplished in c++,the compiler starts complaining when i use _beginthread().
compiler: dmc
os: windows xp
how is concurrent programming accomplished in c++,the compiler starts complaining when i use _beginthread().
compiler: dmc
os: windows xp
Hi
You can use Win32 CreateThread() system call. This allows you to get more control on your thread. Also, MSDN website includes detailed information about multithreaded programming under Win32 environment.
You may want to check the address below
http://msdn.microsoft.com/library/de...ing_Topics.asp
Read the compiler documentions.
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
why doesnt c++ support threads?
and is the _beginthread() function of the c langauge compiler specific or is it a standard.
i was lookin for information about multithreading with c++,
i came across posix threads,i dont know much about them,and my compiler doesnt include the pthread.h anyway even though it is right there in its include folder,who knows why.
i suppose u cant include pthread in a windows environment?
and i also came across some literature on how to have a thread wrapper class,is it required?,this is not java anyway.
and i am lookin for a non mfc way of working with threads.
Well, MS provides you a MFC interface for Win32 C++, but you say you don't want, why?
>why doesnt c++ support threads?
If you use C++ you can still use Win32 C API! C also does not support in standarts. You have to emplay additional libraries in order to use threads.
Did you try google to see whether or not POSIX threads (pthread) can be used under Windows!?
The first link from goole
http://sourceware.org/pthreads-win32/
I think threading is the duty of OS, not the compiler.
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
>I think threading is the duty of OS, not the compiler.
The compiler also can do threading. Actually Linux is not full multithreaded system. When you create a process there is only only one main thread running in it. Still, (I am not sure) the thread support is not a part of kernel. It is implemented by using pthread library.
You can also write your own thread library, but it requires deep knowledge of process management (Scheduling, etc...).
On the other hand, Windows has CreateThread() system call which enables you to create a thread inside of a process (prorbably created with CreateProcess()).
> Well, MS provides you a MFC interface for Win32 C++, but you say you don't want, why?
well that introduces platform dependencies,the code is not portable,what if i dont have access to a windows system and i have to use linux,do i have to rewrite the whole thing?
or i have to download special translation libraries?
Use precompiler conditioning.
I learned aimple multi threading yesterday from adrianxw tutorial. Include process.h and use _beginthread() to call a function as a new thread. I don't know linux but I think when there is no portable code, you should use precompiler conditioning like this:
Code:#define LINUX //Change it whenever you want. #if defined LINUX //LINUX calls #elif defined WINDOWS //Windows calls #endif
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
use boost.threads. it's a portable threading system written by some of the best C++experts around.
"I saw a sign that said 'Drink Canada Dry', so I started"
-- Brendan Behan
Free Compiler: Visual C++ 2005 Express
If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?
If you care about portablity just visit the link a posted. Any popular UNIX system support POSIX threads and you can use pthread under Windows. If you want, you can statically link the libraries under windows.
boost.threads uses the native threading system on each platform and is likely to become the standard c++ threading interface. It's a fully realised object oriented interface, why wouldn't you use that over pthread, (which IIRC, is a c interface)?
http://www.boost.org/libs/thread/doc/index.html
"I saw a sign that said 'Drink Canada Dry', so I started"
-- Brendan Behan
Free Compiler: Visual C++ 2005 Express
If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?