I\'m writing a java program and, before I call a method that makes heavy use of the CPU, I display a frame with a JProgressBar on it. Although I display it before the method is
You should call the heavyLoadMethod
in a separate thread. You can use a java.util.concurrent.Executor
for it:
Executor executor = java.util.concurrent.Executors.newSingleThreadExecutor();
executor.submit(new Runnable() { public void run() { heavyLoadMethod();}});
Now the method will be called in a separate thread and the progress bar will be displayed properly.