java.lang.Thread Java Examples

The following examples show how to use java.lang.Thread. 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 vote down vote up
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
Example #2
Source File: Warlight2.java    From warlight2-engine with Apache License 2.0 6 votes vote down vote up
/**
 * close the bot processes, save, exit program
 */
@Override
public void finish() throws Exception
{
	this.player1.getBot().finish();
	this.player2.getBot().finish();
	Thread.sleep(100);

	// write everything
	try { 
		this.saveGame(); 
	} catch(Exception e) {
		e.printStackTrace();
	}
	
	System.out.println("Done.");
	
       System.exit(0);
}
 
Example #3
Source File: DisplayChangeVITest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
 
Example #4
Source File: DisplayChangeVITest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
 
Example #5
Source File: DisplayChangeVITest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
 
Example #6
Source File: Spider.java    From PADListener with GNU General Public License v2.0 6 votes vote down vote up
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 #7
Source File: DisplayChangeVITest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
 
Example #8
Source File: DisplayChangeVITest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
 
Example #9
Source File: DisplayChangeVITest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
 
Example #10
Source File: DisplayChangeVITest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
 
Example #11
Source File: TexasHoldem.java    From texasholdem-engine with Apache License 2.0 6 votes vote down vote up
@Override
// close the bot processes, save, exit program
public void finish() throws Exception
{
	for(Player player : players) {
		player.getBot().finish();
	}
	Thread.sleep(100);

	// write everything
	try { 
		this.saveGame(); 
	} catch(Exception e) {
		e.printStackTrace();
	}
	
	System.out.println("Done.");
	
       System.exit(0);
}
 
Example #12
Source File: DisplayChangeVITest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
 
Example #13
Source File: Standby.java    From RDFS with Apache License 2.0 6 votes vote down vote up
/**
 * Instantiates ingest thread for the given edits file type
 * 
 * @param type (EDITS, EDITS_NEW)
 */
private void instantiateIngest(IngestFile type)
    throws IOException {
  File edits;
  InjectionHandler.processEvent(InjectionEvent.STANDBY_INSTANTIATE_INGEST);
  synchronized (ingestStateLock) {
    assertState(StandbyIngestState.NOT_INGESTING);
    edits = getIngestFile(type);
    // if the file does not exist, 
    // do not change the state
    if (!edits.exists()
        || InjectionHandler
            .falseCondition(InjectionEvent.STANDBY_EDITS_NOT_EXISTS, type)) {
      return;
    }
    setCurrentIngestFile(edits);
    ingest = new Ingest(this, fsnamesys, confg, edits);
    ingestThread = new Thread(ingest);
    ingestThread.start(); 
    currentIngestState = type == IngestFile.EDITS
        ? StandbyIngestState.INGESTING_EDITS
        : StandbyIngestState.INGESTING_EDITS_NEW;
  } 
  LOG.info("Standby: Instantiated ingest for edits file: " + edits.getName());
}
 
Example #14
Source File: DisplayChangeVITest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
 
Example #15
Source File: DisplayChangeVITest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
 
Example #16
Source File: DisplayChangeVITest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
 
Example #17
Source File: JavaFileTest.java    From javapoet with Apache License 2.0 6 votes vote down vote up
@Test public void alwaysQualifySupersedesJavaLangImports() {
  String source = JavaFile.builder("com.squareup.tacos",
      TypeSpec.classBuilder("Taco")
          .addField(Thread.class, "thread")
          .alwaysQualify("Thread")
          .build())
      .skipJavaLangImports(true)
      .build()
      .toString();
  assertThat(source).isEqualTo(""
      + "package com.squareup.tacos;\n"
      + "\n"
      + "class Taco {\n"
      + "  java.lang.Thread thread;\n"
      + "}\n");
}
 
Example #18
Source File: TourTheStairs.java    From jessica with MIT License 5 votes vote down vote up
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 #19
Source File: TestPrintRegionRememberedSetInfo.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
Example #20
Source File: PhoenixStatsCacheLoaderTest.java    From phoenix with Apache License 2.0 5 votes vote down vote up
void sleep(int x) {
    try {
        Thread.sleep(x);
    }
    catch (InterruptedException e) {
        assertFalse(true);
    }
}
 
Example #21
Source File: TourTheStairs.java    From jessica with MIT License 5 votes vote down vote up
public void land() {
    BluetoothGattCharacteristic characteristics;
    characteristics = uuid2characteristics("9a66fa0b-0800-9191-11e4-012d1540cb8e"); // handle 0x43
    byte [] arr = { 4, (byte)mSettingsCounter, 2, 0, 3, 0 };
    characteristics.setValue( arr );
    mBluetoothLeService.writeCharacteristic(characteristics);
    try {
        Thread.sleep(50);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    mSettingsCounter++;
}
 
Example #22
Source File: ThreadStochModelInstance.java    From OpenDA with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void compute(ITime targetTime) {
block();
      ThreadStochModelAdmin admin = (ThreadStochModelAdmin) threadAdmins.get(factoryID);
threadID=admin.waitUntilFreeThread();
threadModelCompute = new ThreadStochModelCompute(threadModel, targetTime);
threadModelCompute.start();
admin.setThread(threadID, (Thread) threadModelCompute);

// Start Thread for the getState method
if (cashState){
	this.threadModelGetState = new ThreadStochModelGetState(threadModel, threadModelCompute);
	this.threadModelGetState.start();
}
  }
 
Example #23
Source File: TestPrintRegionRememberedSetInfo.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
Example #24
Source File: JavaFileTest.java    From javapoet with Apache License 2.0 5 votes vote down vote up
@Test public void importStaticMixed() {
  JavaFile source = JavaFile.builder("com.squareup.tacos",
      TypeSpec.classBuilder("Taco")
          .addStaticBlock(CodeBlock.builder()
              .addStatement("assert $1T.valueOf(\"BLOCKED\") == $1T.BLOCKED", Thread.State.class)
              .addStatement("$T.gc()", System.class)
              .addStatement("$1T.out.println($1T.nanoTime())", System.class)
              .build())
          .addMethod(MethodSpec.constructorBuilder()
              .addParameter(Thread.State[].class, "states")
              .varargs(true)
              .build())
          .build())
      .addStaticImport(Thread.State.BLOCKED)
      .addStaticImport(System.class, "*")
      .addStaticImport(Thread.State.class, "valueOf")
      .build();
  assertThat(source.toString()).isEqualTo(""
      + "package com.squareup.tacos;\n"
      + "\n"
      + "import static java.lang.System.*;\n"
      + "import static java.lang.Thread.State.BLOCKED;\n"
      + "import static java.lang.Thread.State.valueOf;\n"
      + "\n"
      + "import java.lang.Thread;\n"
      + "\n"
      + "class Taco {\n"
      + "  static {\n"
      + "    assert valueOf(\"BLOCKED\") == BLOCKED;\n"
      + "    gc();\n"
      + "    out.println(nanoTime());\n"
      + "  }\n"
      + "\n"
      + "  Taco(Thread.State... states) {\n"
      + "  }\n"
      + "}\n");
}
 
Example #25
Source File: LanternRTC.java    From webrtc-java with Apache License 2.0 5 votes vote down vote up
public void waitDelaysFinish() {
    try {
        Thread.sleep(100);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
 
Example #26
Source File: TestPrintRegionRememberedSetInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
Example #27
Source File: StatusBar.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void run() {
   bIsAlive = true;
   while(bRun && !isBroken()) {
     updateProgress(-1);
     try {
Thread.sleep(delay);
     } catch (Exception e) { }
   }
   bIsAlive = false;
   runner = null;
 }
 
Example #28
Source File: TestPrintRegionRememberedSetInfo.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
Example #29
Source File: TestPrintRegionRememberedSetInfo.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
Example #30
Source File: AudioCaptureThread.java    From speech-android-sdk with Apache License 2.0 5 votes vote down vote up
public void end() {
    mStop = true;
    // waiting loop, it waits until the thread actually finishes
    while(!mStopped) {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    };
}