Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Never ending function problem

Tags:

c++

Im trying to run a function that will never end (until the program is killed)

How would i start such a function and be able to continue on past that function, because at the moment the program will not run past the never ending function.

Regards

Paul

like image 538
paultop6 Avatar asked Dec 29 '25 19:12

paultop6


1 Answers

You'd need to start a new thread. A given thread can only execute one function at a time. So, if you want to have two separate functions executing at the same time, you need multiple threads. You'll need to look into multi-threaded programming. If you're on linux or another unix-based system, then the library to look at would be pthreads.

like image 112
Jonathan M Davis Avatar answered Jan 01 '26 10:01

Jonathan M Davis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!