Search code examples
c++timeseconds

How to make C++ program doing 2 things simultaneously?


Can someone tell me what do I need to do (not to write me code, just tell me) to make C++ doing 2 things simultaneously?

Let's say that I have some timer and some text. That text moves every 0.5 seconds to the right and times updates every 1 second.

How can I make that ? Don't write me code, as I said, just tell me are there some useful functions. If I am unclear, I will delete this question so it's downovoted (tell me please :). Thank you!


Solution

  • One way to do multiple things at the same time in a C++ program is to use threads. That a look at std::thread for more information.

    The point being that the threads run independently of one another and can perform completely separate tasks at the same time.

    The advantage of using std::thread is that it's portable, so your code is no longer dependent on what operating system you're using.