House building analogy
This example application demonstrates why concurrency and parallelism are needed in modern software applications. Points of interest:
- Run in Sequential mode first. Notice that the GUI freezes, and only one CPU-core is used on your system. Note the time (printed to console).
- Now run it in Concurrent mode. Notice that the GUI doesn't freeze this time, but still only one CPU-core is used on your system. Note the time (printed to console), which will most likely actually be slower than Sequential even though it appeared more responsive!
- Now run it in Parallel mode. The GUI doesn't freeze, and you will notice all your CPU-cores are used. Note the time (printed to console), which will be a lot faster.
If you didn't get the speedup you expected (e.g. you only got 2.5x on a "4-core" processor) it will be because you have hyper-threading.
You may download the house example
here
- Run from the command line > java -jar house.jar