Updating array using multiple threads java
Additional you can make another thread that does a Wait All() and informs the GUI that all threads are ready.But using a do-loop until one or more threads are ready is a sin. 1) It doesn't block the user because threads are independent and you can perform multiple operations at same time.
Thread is basically a lightweight sub-process, a smallest unit of processing.
Declaring the field volatile makes changes made by one thread visible to all other threads.
As a writing thread do not read the value, point b “the value is not changed during the update by the other thread” is fulfilled.
In a real world app you can start different threads but probably you don't have any info about the progress, unless each thread post some progress to the main thread.
A busy animation would to better Another common mistake if you have a worker thread posting progress on every action: Worker thread .while not eof ..readline ..postprogress (fileposition / filesize) To make your application 'safe' to run on a produtional machine you could let each thread post a 'ready' notification.
You can use it only for single valued fields like boolean or int.