more robust test
Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
cd7432da95
commit
48eebacd6c
|
@ -102,7 +102,7 @@ public class ProduceExecuteConsume implements ExecutionStrategy
|
||||||
@Override
|
@Override
|
||||||
public void dispatch()
|
public void dispatch()
|
||||||
{
|
{
|
||||||
produce();
|
_executor.execute(()->produce());
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum State
|
private enum State
|
||||||
|
|
|
@ -160,13 +160,12 @@ public class ExecutionStrategyTest
|
||||||
{
|
{
|
||||||
final int id = --tasks;
|
final int id = --tasks;
|
||||||
if (id>=0)
|
if (id>=0)
|
||||||
|
{
|
||||||
|
while(_threads.isRunning())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final CountDownLatch latch = q.take();
|
final CountDownLatch latch = q.take();
|
||||||
|
|
||||||
if (latch!=null)
|
|
||||||
{
|
|
||||||
return new Runnable()
|
return new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -177,20 +176,19 @@ public class ExecutionStrategyTest
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch(InterruptedException e)
|
catch(InterruptedException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
newExecutionStrategy(producer,_threads);
|
newExecutionStrategy(producer,_threads);
|
||||||
_threads.execute(()->_strategy.produce());
|
_strategy.dispatch();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(TASKS);
|
final CountDownLatch latch = new CountDownLatch(TASKS);
|
||||||
|
|
Loading…
Reference in New Issue