RFR: 8081474: SwingWorker calls 'done' before the 'doInBackground' is finished [v3]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Mon Jan 30 08:37:19 UTC 2023
On Sun, 29 Jan 2023 14:32:11 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Remove blocking thread sleep for EDT
>
> src/java.desktop/share/classes/javax/swing/SwingWorker.java line 762:
>
>> 760: } catch (InterruptedException e) {}
>> 761: } while (state != StateValue.DONE);
>> 762: }
>
> In the previous iteration, using `sleep` for waiting was *the concern*, you're still using `sleep`.
>
> This is not going to work because it makes `cancel` wait until `DONE` state is reached, which is not what one would expect, especially taking into account that `cancel` is likely called from EDT to cancel the background operation and blocking EDT is not acceptable.
I removed sleep from EDT case and not blocking EDT and guess sleep is now being done for non-EDT case...
If it is to be called from EDT then it should go to "if" block and not to "else" which is what I based my fix on..
Anyway, I appreciate your fix and will see to it..
-------------
PR: https://git.openjdk.org/jdk/pull/11940
More information about the client-libs-dev
mailing list