Okay, so I have a project where I need to be able to generate a Thread whenever an Action's process() method is started, then automatically terminate the thread when process() ends. However, I have no clue how to do that. I've tried using the Executor(?) class for this, but I haven't gotten it to work.
Minimal Reproducible Example
I need to be able to run both Action1 and Action2's process() methods in parallel. (process() might not exist in this example and might instead be the Runnable's run() method)
#How to procedurally generate Threads?
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
may i ask why? the default thread pools already are faster than anything u can create. so if ur goal is to have the fastest execution of ur tasks, just throw them at the default pool through the CompletableFuture api and call it a day
Could you explain more what you mean by that? I've never used that API (or any API with Java for that matter)
I'm trying to get the actions to run in parallel because there are supposed to have multiple instances of the actions at once
It's for a game I'm making
I have an effect that deals damage of a series of turns, and another one that does another action over a series of turns and I need them to be able to run in parallel to the main game function
well, you simply do CompletableFuture.runAsyn(...) and you have the task running in parallel and java takes care of the thread management for u, resulting in the fastest way to execute it
much faster than what u can achieve managing threads urself
No boiler plate for the api?
/help-thread close