> 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).

Arno Zeller has updated the pull request incrementally with one additional 
commit since the last revision:

  Add timeout to CountDownLatch and use Utils.adjustTimeout.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/31348/files
  - new: https://git.openjdk.org/jdk/pull/31348/files/0208eb91..7c9851a1

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=31348&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=31348&range=01-02

  Stats: 7 lines in 1 file changed: 5 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/31348.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/31348/head:pull/31348

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

Reply via email to