How can I wait, in the second thread, the termination of the display in the GUI thread for each picture.