Relative Content

Tag Archive for javamultithreadingswingparallel-processingsemaphore

How can I do a progressive bar with JProgressBar from Swing on Java?

I’m a beginner on parallel computing. I’ve been working on Java in Apache Netbeans. My recent work was about semaphores, using the Semaphore and Thread Java classes, in that sense, I had to make a program that simulates with progress bars a credit card delivery process that depends on five sub processes (simulated with the threads). Each sub process has a time that is simulated in the program, in this case, using the method sleep from the threads. The semaphore implementation is to progressively increment the general bar depending on the other processes, if one of these is completed then it can be filled in the general bar. Something extra to add is that the sub processes also have their respective progress bars. My problem occurs in the classes BarraGeneral and SubProceso, these represent the general process and one sub process. In their overriden run methods is where I simulate the time and, of course, I do the drawing, but this is not happening. I can say it actually works because on console you can check the prints, the problem as I said is that the bars are not reflecting this progress, it just goes from 0% to 100%.