This is a simple little project with functional FRunnable threads.
To try it out:
- Compile in your favorite IDE
- Launch
UEditor - Start PIE
Once in PIE, you'll see this widget at the top left of the viewport:
You can change the number of threads to whatever you want and click the Start button to spawn the threads.
The threads "work" by sleeping for a random 0.5 - 2.5 seconds. After working, there is a 90% chance for the thread to pretend there is more work to do. Thus, all threads will eventually randomly decide they are done working.
At any time you can click the Stop button to instruct the threads to exit ASAP.
This widget is super simple and doesn't do anything interesting.
It only interfaces with the AXistPlayerController C++ class, which is what does the interesting stuff.
This is the actual FRunnable thread class, the central idea explored in this project.
The Player Controller is what actually manages the threads in this project. You can ignore most of it, except for these interesting methods:
- Called by the widget to start
NumFRunnableNonsensethreads- Invoked by the
Startbutton
- Invoked by the
- Called by the widget to stop all running
FRunnableNonsensethreads- Invoked by the
Stopbutton
- Invoked by the
- Detects
FRunnableNonsensethreads that have exited and cleans up the memory associated with them
- Cleans up any remaining
FRunnableNonsensethreads that are still running
The widget BP is super simple, all it does is call the above methods
in the AXistPlayerController.

