mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-16 23:12:47 +00:00
enable use of more than a single background thread
This commit is contained in:
parent
51c906863d
commit
99081527ad
1 changed files with 5 additions and 1 deletions
|
@ -29,7 +29,11 @@ public class ExecutorUtils {
|
|||
private static ScheduledExecutorService sSpellingExecutorService = newExecutorService(SPELLING);
|
||||
|
||||
private static ScheduledExecutorService newExecutorService(final String name) {
|
||||
return Executors.newSingleThreadScheduledExecutor(new ExecutorFactory(name));
|
||||
// use more than a single thread, to reduce the occasional wait (mostly relevant when using multiple languages)
|
||||
// limit number to cores / 2 to never interfere with whatever some other app is doing
|
||||
final int cores = Runtime.getRuntime().availableProcessors();
|
||||
final int threads = Math.max(cores / 2, 1);
|
||||
return Executors.newScheduledThreadPool(threads, new ExecutorFactory(name));
|
||||
}
|
||||
|
||||
private static class ExecutorFactory implements ThreadFactory {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue