Slightly better practice because wait can be randomly interupted.
This commit is contained in:
parent
4248dbc71d
commit
42404c531d
1 changed files with 11 additions and 8 deletions
|
@ -45,7 +45,9 @@ public class ChunkIOExecutor
|
|||
ChunkIOProvider task = tasks.get(key);
|
||||
if (task != null)
|
||||
{
|
||||
if (!pool.remove(task) && !task.runFinished()) // If it wasn't in the pool, and run hasn't finished, then wait for the async thread.
|
||||
if (!pool.remove(task)) // If it wasn't in the pool, and run hasn't finished, then wait for the async thread.
|
||||
{
|
||||
while (!task.runFinished())
|
||||
{
|
||||
synchronized(task)
|
||||
{
|
||||
|
@ -60,6 +62,7 @@ public class ChunkIOExecutor
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
task = new ChunkIOProvider(key);
|
||||
|
|
Loading…
Reference in a new issue