[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/109152] VMProcess.<init>()/destroy() affect thread interr
From: |
lgcat76 at gmail dot com |
Subject: |
[Bug classpath/109152] VMProcess.<init>()/destroy() affect thread interrupt flag |
Date: |
Thu, 16 Mar 2023 06:46:04 +0000 |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109152
--- Comment #1 from L. G. C. <lgcat76 at gmail dot com> ---
Possible solution can be using a method like this:
----------------------------------------------------------------
// Must be called with this instance's lock held (i.e. synchronized on this)
private void waitStateUninterruptibly(int state, boolean value)
{
boolean interrupted = Thread.interrupted();
while ((this.state == state) != value)
{
try
{
wait();
}
catch (InterruptedException e)
{
interrupted = true;
}
}
// Keep interrupt flag unaltered
if (interrupted)
Thread.currentThread().interrupt();
}
----------------------------------------------------------------
And replacing the current wait loops with calls to that method:
waitStateUninterruptibly(INITIAL, false);
and
waitStateUninterruptibly(TERMINATED, true);