Why is my threaded program only using one CPU?
cpu, java, multithreading
Solution
You aren't actually using threads.
You need to call `.start()`, not `.run()`.
Problem
I have a program that performs a long-time computations, so I want to speed up its performance. So I tried to launch 3 threads at the moment, but `java.exe` still occupies 25% of CPU usage (so, only one CPU is used), and it's remains even if I try to use `.setPriority(Thread.MAX_PRIORITY);` and set priority of `java.exe` at realtime (24). I tried to use `RealtimeThread` but seems like it works even slower. It would be perfect if each thread was allocated to one processor and the total CPU usage has increased to 75%, but I don't know how to do it. And that's how my code looks right now: ``` Thread g1 = new MyThread(i,j); g1.setPriority(Thread.MAX_PRIORITY); g1.run(); Thread g2 = new MyThread(j,i); g2.setPriority(Thread.MAX_PRIORITY); g2.run(); Thread g3 = new MyThread(i,j); g3.setPriority(Thread.MAX_PRIORITY); g3.run(); if (g1.isAlive()) { g1.join(); } if (g2.isAlive()) { g2.join(); } if (g3.isAlive()) { g3.join(); } ```