Fixed test with atomic

the --task was not protected with a memory barrier, so different producing threads could contend on the field.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2018-03-14 15:59:37 +11:00
parent f34f23f20f
commit a810ecf67e
1 changed files with 2 additions and 2 deletions

View File

@ -156,11 +156,11 @@ public class ExecutionStrategyTest
Producer producer = new TestProducer() Producer producer = new TestProducer()
{ {
int tasks=TASKS; AtomicInteger tasks = new AtomicInteger(TASKS);
@Override @Override
public Runnable produce() public Runnable produce()
{ {
final int id = --tasks; final int id = tasks.decrementAndGet();
if (id>=0) if (id>=0)
{ {
while(_threads.isRunning()) while(_threads.isRunning())