In my program I need to execute two loops at same time. How can I do that? As windows have multi processing can I too complete two or more processes at same time? Actually I need 3 different timers which will be running simultaneously.

Recommended Answers

All 3 Replies

In turbo C++ 3.0, I've no idea. Could be anything.

If you were using something a bit mroe modern, I'd point you at the C++ 11 threading library, or a standard third-party threading library like pthreads or the Win32 threading libraries.

Try using 3 different variables in same loop.

Normally, I would direct people either to the C++11 threading library or to its precursor, the Boost.Thread library, as the best, most portable and easiest multi-threading library to use. However, these will certainly not work with Turbo C++ 3.0.

Your best chance is with the Win32 API functions. To create a thread, you can use the function CreateThread.

The issue you will face is probably the fact that Turbo C++ 3.0 is most likely packaged with an ancient version of the Windows APIs, and I can't say for sure whether it can even work with more recent versions. The version of the Win32 API that Turbo C++ 3.0 comes with probably dates to some time when people would be using Windows 3.0 / 3.1, if they were using Windows at all (probably MS-DOS). In either case, multi-threading was not supported in those days (i.e., it just didn't really exist yet). If you have a post-Windows95 version of Turbo C++ 3.0, then there is a chance that it comes with the earliest version of Win32 API, the one used for making applications for Windows 95 or NT. If that's the case, I would assume that CreateThread (and its related functions) probably do exist. But one thing's for sure, you'll have a very hard time finding documentation on this (people would, quite expectingly, rely heavily on MSDN for documentation on Microsoft stuff, but MSDN is not known for its "archiving" qualities, I don't think there is much useful information about anything older than Windows 2000 / XP).

In other words, get a more modern compiler! Multi-threading is not something you want to do with a compiler that was developed before multi-threading even existed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.