First of all, is there a need to wait for the thread operation inside the Button handler? Normally, u create a worker thread to perform certain operations so that your GUI can continue to receive user action.