Java Code Examples for java.util.concurrent.atomic.AtomicBoolean#notify()
The following examples show how to use
java.util.concurrent.atomic.AtomicBoolean#notify() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSpeculation.java From tez with Apache License 2.0 | 5 votes |
/** * Sync with mock app launcher. * * @param allowScheduling the allow scheduling * @param mockAppLauncherGoFlag the mock app launcher go flag * @param tezClient the tez client * @throws Exception the exception */ void syncWithMockAppLauncher(boolean allowScheduling, AtomicBoolean mockAppLauncherGoFlag, MockTezClient tezClient) throws Exception { synchronized (mockAppLauncherGoFlag) { while (!mockAppLauncherGoFlag.get()) { mockAppLauncherGoFlag.wait(); } mockApp = tezClient.getLocalClient().getMockApp(); mockLauncher = mockApp.getContainerLauncher(); mockLauncher.startScheduling(allowScheduling); mockAppLauncherGoFlag.notify(); } }
Example 2
Source File: TestPreemption.java From tez with Apache License 2.0 | 5 votes |
void syncWithMockAppLauncher(boolean allowScheduling, AtomicBoolean mockAppLauncherGoFlag, MockTezClient tezClient) throws Exception { synchronized (mockAppLauncherGoFlag) { while (!mockAppLauncherGoFlag.get()) { mockAppLauncherGoFlag.wait(); } mockApp = tezClient.getLocalClient().getMockApp(); mockLauncher = mockApp.getContainerLauncher(); mockLauncher.startScheduling(allowScheduling); mockAppLauncherGoFlag.notify(); } }
Example 3
Source File: BaseTransformTest.java From hop with Apache License 2.0 | 4 votes |
@Test public void testTransformListenersConcurrentModification() throws InterruptedException { // Create a base transform final BaseTransform baseTransform = new BaseTransform( mockHelper.transformMeta, mockHelper.iTransformMeta, mockHelper.iTransformData, 0, mockHelper.pipelineMeta, mockHelper.pipeline ); // Create thread to dynamically add listeners final AtomicBoolean done = new AtomicBoolean( false ); Thread addListeners = new Thread() { @Override public void run() { while ( !done.get() ) { baseTransform.addTransformFinishedListener( mock( ITransformFinishedListener.class ) ); synchronized ( done ) { done.notify(); } } } }; // Mark start and stop while listeners are being added try { addListeners.start(); // Allow a few listeners to be added synchronized ( done ) { while ( baseTransform.getTransformFinishedListeners().size() < 20 ) { done.wait(); } } baseTransform.markStart(); // Allow more listeners to be added synchronized ( done ) { while ( baseTransform.getTransformFinishedListeners().size() < 100 ) { done.wait(); } } baseTransform.markStop(); } finally { // Close addListeners thread done.set( true ); addListeners.join(); } }
Example 4
Source File: BaseStepTest.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Test public void testStepListenersConcurrentModification() throws InterruptedException { // Create a base step final BaseStep baseStep = new BaseStep( mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans ); // Create thread to dynamically add listeners final AtomicBoolean done = new AtomicBoolean( false ); Thread addListeners = new Thread() { @Override public void run() { while ( !done.get() ) { baseStep.addStepListener( mock( StepListener.class ) ); synchronized ( done ) { done.notify(); } } } }; // Mark start and stop while listeners are being added try { addListeners.start(); // Allow a few listeners to be added synchronized ( done ) { while ( baseStep.getStepListeners().size() < 20 ) { done.wait(); } } baseStep.markStart(); // Allow more listeners to be added synchronized ( done ) { while ( baseStep.getStepListeners().size() < 100 ) { done.wait(); } } baseStep.markStop(); } finally { // Close addListeners thread done.set( true ); addListeners.join(); } }