On Tue, 2 Jun 2026 09:04:17 GMT, Arno Zeller <[email protected]> wrote:

> The doInBackground working loop is left because of the loop condition 
> (!Thread.currentThread().isInterrupted()) - this will not clear the 
> interrupted status of the thread and the Thread.sleep at line 63 will throw 
> an InterruptedException directly.
> I suggest to change two things:
> No longer check the !Thread.currentThread().isInterrupted() but rely only on 
> the Thread.sleep to throw an InterrutedException.
> And using a countdown latch instead of a sleep to ensure that we really 
> entered the loop before we do cancel the worker.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: a47f3620
Author:    Arno Zeller <[email protected]>
Committer: Matthias Baesken <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/a47f3620f2cae26e2e3f3642bd26871fdd02fddb
Stats:     16 lines in 1 file changed: 12 ins; 0 del; 4 mod

8382063: Jtreg test javax/swing/SwingWorker/TestDoneBeforeDoInBackground.java 
fails

Reviewed-by: mbaesken, aivanov, azvegint, clanger, syan

-------------

PR: https://git.openjdk.org/jdk/pull/31348

Reply via email to