Skip to content

Use a common thread pool instead of creating new threads manually

Summary

Spawning new threads in Java is costly. This MR aims to use a common thread pool instead.

I've replaced all cases where a new thread is started just to perform a task in the background. This does not include cases where a reference to the newly created thread is kept as a part of application logic – this is probably a problem in itself, but it exceeds the scope of this quick optimization. ;)

There was a couple of cases where a new thread was spawned just to sleep for a while an then change the state on a View on the main thread. I've replaced those with posting those deferred tasks to the View's message queue.

Test Plan

Everything should work the same as it has before, just a bit faster and easier on the memory.

Merge request reports