I’m trying to multithread my java application with ScheduledThreadPoolExecutor. I do this by submitting the tasks to the future list and then try to retrieve the results from the future list. However, for some reason, it still only utilizes one core on the computer when I run htop.
In addition, the processes sometimes hang, which i suspect to be because of the libraries i’m using, so what would be a good way to implement essentially a time limit, after which the thread restarts with a new object?
Thanks.
You cannot kill a thread safely you cna only interrupted is so it cna shut itself down. If you need to kill a thread running alibrary you need to run in is a seperate process.
To use more than one CPU you need to have more than one CPU intensive task. If you are running one task at a time, you will use at most one core.