Java Swing multi thread loading pictures (ensure consistent order)
When I was a sophomore, I did the course design and picture manager. At that time, I encountered many folders with pictures, and the loading order was very slow. Although trying to load pictures with multiple threads, there is no guarantee that the pictures will be loaded in order. Until today, I learned to use the callable interface and future interface, so I realized this function on a whim.
No more nonsense, look at the code.
Multithreaded loading pictures (core):
Swing interface:
Operation results
On my computer, it took 1568 milliseconds to load 92 pictures and render them to the interface. You can find a folder with many pictures and try to load a large number of pictures.
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.