Java Code Examples for java.lang.Thread#sleep()
The following examples show how to use
java.lang.Thread#sleep() .
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: TestPrintRegionRememberedSetInfo.java From TencentKona-8 with GNU General Public License v2.0 | 8 votes |
public static void main(String[] args) { System.gc(); try { Thread.sleep(200); } catch (InterruptedException e) { } }
Example 2
Source File: Listener.java From PADListener with GNU General Public License v2.0 | 6 votes |
public boolean stop() { _stop = true; try { _serversocket.close(); } catch (IOException e) { e.printStackTrace(); } if (!_stopped) { for (int i=0; i<20; i++) { try { Thread.sleep(100); } catch (InterruptedException ie) {} if (_stopped) { return true; } } return false; } else { return true; } }
Example 3
Source File: Spider.java From PADListener with GNU General Public License v2.0 | 6 votes |
public void run() { _model.setStatus("Started"); _model.setStopping(false); _runThread = Thread.currentThread(); _model.setRunning(true); while (!_model.isStopping()) { // queue them as fast as they come, sleep a bit otherwise if (!queueRequests()) { try { Thread.sleep(100); } catch (InterruptedException ie) {} } else { Thread.yield(); } } _fetcherQueue.clearRequestQueue(); _model.setRunning(false); _runThread = null; _model.setStatus("Stopped"); }
Example 4
Source File: TestPrintRegionRememberedSetInfo.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { System.gc(); try { Thread.sleep(200); } catch (InterruptedException e) { } }
Example 5
Source File: TestPrintRegionRememberedSetInfo.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { System.gc(); try { Thread.sleep(200); } catch (InterruptedException e) { } }
Example 6
Source File: Standby.java From RDFS with Apache License 2.0 | 5 votes |
private void pollEditsNew(int numRetries) throws IOException { for (int i = 0; i < numRetries; i++) { if (editsNewExists()) break; try { Thread.sleep(1000); } catch (InterruptedException e) { throw new IOException("Standby: - received interruption"); } LOG.info("Standby: - retrying to check if edits.new exists... try: " + i); } }
Example 7
Source File: TourTheStairs.java From jessica with MIT License | 5 votes |
public void emergencyStop() { // dangerous - stops all motors! BluetoothGattCharacteristic characteristics; characteristics = uuid2characteristics("9a66fa0c-0800-9191-11e4-012d1540cb8e"); // handle 0x46 byte [] arr = { 4, (byte)mEmergencyCounter, 2, 0, 4, 0 }; characteristics.setValue( arr ); mBluetoothLeService.writeCharacteristic(characteristics); try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } mEmergencyCounter++; }
Example 8
Source File: HistoryServerOperator.java From spark-operator with Apache License 2.0 | 5 votes |
private void updateStatus(SparkHistoryServer hs, String state) { for (int i=0; i<3; i++) { try { setCRStatus(state, hs.getNamespace(), hs.getName() ); break; } catch(Exception e) { log.warn("failed to update status {} for {} in {}", state, hs.getName(), hs.getNamespace()); try {Thread.sleep(500);} catch(Exception t) {} } } }
Example 9
Source File: LanternRTC.java From webrtc-java with Apache License 2.0 | 5 votes |
public void waitDelaysFinish() { try { Thread.sleep(100); } catch (InterruptedException e) { throw new RuntimeException(e); } }
Example 10
Source File: FullScreenAfterSplash.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { System.out.println("The test is applicable only to Mac OS X. Passed"); return; } try { //Move the mouse out, because it could interfere with the test. Robot r = new Robot(); r.mouseMove(0, 0); sleep(); SwingUtilities.invokeAndWait(FullScreenAfterSplash::createAndShowGUI); sleep(); Point fullScreenButtonPos = frame.getLocation(); fullScreenButtonPos.translate(frame.getWidth() - 10, 10); r.mouseMove(fullScreenButtonPos.x, fullScreenButtonPos.y); //Cant use waitForIdle for full screen transition. int waitCount = 0; while (!windowEnteringFullScreen) { r.mousePress(InputEvent.BUTTON1_MASK); r.mouseRelease(InputEvent.BUTTON1_MASK); Thread.sleep(100); if (waitCount++ > 10) { System.err.println("Can't enter full screen mode. Failed."); System.exit(1); } } waitCount = 0; while (!windowEnteredFullScreen) { Thread.sleep(100); if (waitCount++ > 10) { System.err.println("Can't enter full screen mode. Failed."); System.exit(1); } } } finally { if (frame != null) { frame.dispose(); } } }
Example 11
Source File: FullScreenAfterSplash.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private static void sleep() { try { Thread.sleep(500); } catch (InterruptedException ignored) { } }
Example 12
Source File: FullScreenAfterSplash.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { System.out.println("The test is applicable only to Mac OS X. Passed"); return; } try { //Move the mouse out, because it could interfere with the test. Robot r = new Robot(); r.mouseMove(0, 0); sleep(); SwingUtilities.invokeAndWait(FullScreenAfterSplash::createAndShowGUI); sleep(); Point fullScreenButtonPos = frame.getLocation(); fullScreenButtonPos.translate(frame.getWidth() - 10, 10); r.mouseMove(fullScreenButtonPos.x, fullScreenButtonPos.y); //Cant use waitForIdle for full screen transition. int waitCount = 0; while (!windowEnteringFullScreen) { r.mousePress(InputEvent.BUTTON1_MASK); r.mouseRelease(InputEvent.BUTTON1_MASK); Thread.sleep(100); if (waitCount++ > 10) { System.err.println("Can't enter full screen mode. Failed."); System.exit(1); } } waitCount = 0; while (!windowEnteredFullScreen) { Thread.sleep(100); if (waitCount++ > 10) { System.err.println("Can't enter full screen mode. Failed."); System.exit(1); } } } finally { if (frame != null) { frame.dispose(); } } }
Example 13
Source File: DisplayChangeVITest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private static void sleep(long msec) { try { Thread.sleep(msec); } catch (InterruptedException e) {} }
Example 14
Source File: FullScreenAfterSplash.java From hottub with GNU General Public License v2.0 | 4 votes |
private static void sleep() { try { Thread.sleep(500); } catch (InterruptedException ignored) { } }
Example 15
Source File: GlobalCapabilitiesDirectoryIntegrationTest.java From joynr with Apache License 2.0 | 4 votes |
@Test public void testRemoveStaleProvidersOfClusterController() throws Exception { DiscoveryQos discoveryQos = new DiscoveryQos(); discoveryQos.setDiscoveryScope(DiscoveryScope.GLOBAL_ONLY); discoveryQos.setArbitrationStrategy(ArbitrationStrategy.HighestPriority); discoveryQos.setDiscoveryTimeoutMs(DISCOVERY_TIMEOUT); discoveryQos.setRetryIntervalMs(DISCOVERY_TIMEOUT + 1L); discoveryQos.setCacheMaxAgeMs(0L); MessagingQos messagingQos = new MessagingQos(); messagingQos.setTtl_ms(MESSAGING_TTL); final Future<Void> future = new Future<Void>(); // create first joynr cluster controller runtime runtimeFirst = createRuntime(); // register provider registerProvider(runtimeFirst); // shutdown first cluster controller if (testProvider != null) { testProvider = null; } runtimeFirst.shutdown(false); // create cluster controller second time runtimeSecond = createRuntime(); // wait some time to make sure that removeStale has been published and processed Thread.sleep(1000); // build proxy when provider are unregistered runtimeSecond.getProxyBuilder(TEST_DOMAIN, testProxy.class) .setDiscoveryQos(discoveryQos) .setMessagingQos(messagingQos) .build(new ProxyCreatedCallback<testProxy>() { @Override public void onProxyCreationFinished(testProxy result) { future.onSuccess(null); } @Override public void onProxyCreationError(JoynrRuntimeException error) { future.onFailure(error); } }); try { future.get(5000); fail("runtimeSecond.getProxyBuilder().build() should throw Exception!"); } catch (Exception e) { boolean isFound = e.getMessage().indexOf("Unable to find provider") != -1 ? true : false; assertTrue(isFound); } runtimeSecond.shutdown(true); }
Example 16
Source File: FullScreenAfterSplash.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { System.out.println("The test is applicable only to Mac OS X. Passed"); return; } try { //Move the mouse out, because it could interfere with the test. Robot r = new Robot(); r.mouseMove(0, 0); sleep(); SwingUtilities.invokeAndWait(FullScreenAfterSplash::createAndShowGUI); sleep(); Point fullScreenButtonPos = frame.getLocation(); fullScreenButtonPos.translate(frame.getWidth() - 10, 10); r.mouseMove(fullScreenButtonPos.x, fullScreenButtonPos.y); //Cant use waitForIdle for full screen transition. int waitCount = 0; while (!windowEnteringFullScreen) { r.mousePress(InputEvent.BUTTON1_MASK); r.mouseRelease(InputEvent.BUTTON1_MASK); Thread.sleep(100); if (waitCount++ > 10) { System.err.println("Can't enter full screen mode. Failed."); System.exit(1); } } waitCount = 0; while (!windowEnteredFullScreen) { Thread.sleep(100); if (waitCount++ > 10) { System.err.println("Can't enter full screen mode. Failed."); System.exit(1); } } } finally { if (frame != null) { frame.dispose(); } } }
Example 17
Source File: TourTheStairs.java From jessica with MIT License | 4 votes |
public void init() { // note at at least BD characteristics notification is "must have" otherwise it does not start mBluetoothLeService.setCharacteristicNotification(uuid2characteristics("9a66fb0f-0800-9191-11e4-012d1540cb8e"), true); // 0xCO sleep( 50 ); mBluetoothLeService.setCharacteristicNotification(uuid2characteristics("9a66fb0e-0800-9191-11e4-012d1540cb8e"), true); // 0xBD sleep( 50 ); mBluetoothLeService.setCharacteristicNotification(uuid2characteristics("9a66fb1b-0800-9191-11e4-012d1540cb8e"), true); // 0xE4 sleep( 50 ); mBluetoothLeService.setCharacteristicNotification(uuid2characteristics("9a66fb1c-0800-9191-11e4-012d1540cb8e"), true); // 0xE7 sleep( 50 ); mBluetoothLeService.setCharacteristicNotification(uuid2characteristics("9a66fd22-0800-9191-11e4-012d1540cb8e"), true); // 0x113 sleep( 50 ); mBluetoothLeService.setCharacteristicNotification(uuid2characteristics("9a66fd23-0800-9191-11e4-012d1540cb8e"), true); // 0x116 sleep( 50 ); mBluetoothLeService.setCharacteristicNotification(uuid2characteristics("9a66fd24-0800-9191-11e4-012d1540cb8e"), true); // 0x119 sleep( 50 ); mBluetoothLeService.setCharacteristicNotification(uuid2characteristics("9a66fd52-0800-9191-11e4-012d1540cb8e"), true); // 0x123 sleep( 50 ); mBluetoothLeService.setCharacteristicNotification(uuid2characteristics("9a66fd53-0800-9191-11e4-012d1540cb8e"), true); // 0x126 sleep( 50 ); mBluetoothLeService.setCharacteristicNotification(uuid2characteristics("9a66fd54-0800-9191-11e4-012d1540cb8e"), true); // 0x129 sleep(50); // TODO start all available notifications // setAllNotification(true); for( int i=0; i < 20; i++){ BluetoothGattCharacteristic characteristics; characteristics = uuid2characteristics("9a66fa1e-0800-9191-11e4-012d1540cb8e"); // handle 0x7C byte[] value = new byte[3]; value[0] = (byte) (0x1); value[1] = (byte) (i+1); value[2] = (byte) (i+1); characteristics.setValue(value); mBluetoothLeService.writeCharacteristic(characteristics); try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } }
Example 18
Source File: FullScreenAfterSplash.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { try { //Move the mouse out, because it could interfere with the test. Robot r = new Robot(); r.setAutoDelay(50); r.mouseMove(0, 0); sleep(); SwingUtilities.invokeAndWait(FullScreenAfterSplash::createAndShowGUI); sleep(); Point fullScreenButtonPos = frame.getLocation(); if(System.getProperty("os.version").equals("10.9")) fullScreenButtonPos.translate(frame.getWidth() - 10, frame.getHeight()/2); else fullScreenButtonPos.translate(55,frame.getHeight()/2); r.mouseMove(fullScreenButtonPos.x, fullScreenButtonPos.y); //Cant use waitForIdle for full screen transition. int waitCount = 0; while (!windowEnteringFullScreen) { r.mousePress(InputEvent.BUTTON1_MASK); r.mouseRelease(InputEvent.BUTTON1_MASK); Thread.sleep(100); if (waitCount++ > 10) { System.err.println("Can't enter full screen mode. Failed."); System.exit(1); } } waitCount = 0; while (!windowEnteredFullScreen) { Thread.sleep(100); if (waitCount++ > 10) { System.err.println("Can't enter full screen mode. Failed."); System.exit(1); } } } finally { if (frame != null) { frame.dispose(); } } }
Example 19
Source File: DisplayChangeVITest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static void sleep(long msec) { try { Thread.sleep(msec); } catch (InterruptedException e) {} }
Example 20
Source File: DisplayChangeVITest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private static void sleep(long msec) { try { Thread.sleep(msec); } catch (InterruptedException e) {} }