类java.lang.Thread源码实例Demo

下面列出了怎么用java.lang.Thread的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: javapoet   文件: JavaFileTest.java
@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");
}
 
源代码2 项目: dragonwell8_jdk   文件: DisplayChangeVITest.java
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.");
    }
}
 
源代码3 项目: TencentKona-8   文件: DisplayChangeVITest.java
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.");
    }
}
 
源代码4 项目: jdk8u60   文件: DisplayChangeVITest.java
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.");
    }
}
 
源代码5 项目: openjdk-jdk8u   文件: DisplayChangeVITest.java
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.");
    }
}
 
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.");
    }
}
 
源代码7 项目: openjdk-jdk9   文件: DisplayChangeVITest.java
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.");
    }
}
 
源代码8 项目: jdk8u-jdk   文件: DisplayChangeVITest.java
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.");
    }
}
 
源代码9 项目: hottub   文件: DisplayChangeVITest.java
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.");
    }
}
 
源代码10 项目: jdk8u_jdk   文件: DisplayChangeVITest.java
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.");
    }
}
 
源代码11 项目: jdk8u-jdk   文件: DisplayChangeVITest.java
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.");
    }
}
 
源代码12 项目: texasholdem-engine   文件: TexasHoldem.java
@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);
}
 
源代码13 项目: warlight2-engine   文件: Warlight2.java
/**
 * 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);
}
 
源代码14 项目: jdk8u-dev-jdk   文件: DisplayChangeVITest.java
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.");
    }
}
 
源代码15 项目: PADListener   文件: Spider.java
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");
}
 
源代码16 项目: RDFS   文件: Standby.java
/**
 * 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());
}
 
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
源代码18 项目: javapoet   文件: JavaFileTest.java
@Test public void alwaysQualifySimple() {
  String source = JavaFile.builder("com.squareup.tacos",
      TypeSpec.classBuilder("Taco")
          .addField(Thread.class, "thread")
          .alwaysQualify("Thread")
          .build())
      .build()
      .toString();
  assertThat(source).isEqualTo(""
      + "package com.squareup.tacos;\n"
      + "\n"
      + "class Taco {\n"
      + "  java.lang.Thread thread;\n"
      + "}\n");
}
 
源代码19 项目: jdk8u60   文件: TestPrintRegionRememberedSetInfo.java
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
源代码20 项目: OpenDA   文件: ThreadStochModelInstance.java
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();
}
  }
 
源代码21 项目: openccg   文件: MyNgramCombo.java
static NgramScorer getWordsLM() throws IOException {
NgramScorer retval = lmMap.get(Thread.currentThread());
if (retval != null) {
    lmMap.remove(Thread.currentThread());
    return retval;
}
return new StandardNgramModel(3, wordsLM());
   }
 
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
源代码25 项目: hottub   文件: TestPrintRegionRememberedSetInfo.java
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
public static void main(String[] args) {
    System.gc();
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
    }
}
 
源代码28 项目: knopflerfish.org   文件: StatusBar.java
public void run() {
   bIsAlive = true;
   while(bRun && !isBroken()) {
     updateProgress(-1);
     try {
Thread.sleep(delay);
     } catch (Exception e) { }
   }
   bIsAlive = false;
   runner = null;
 }
 
源代码29 项目: speech-android-sdk   文件: AudioCaptureThread.java
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();
        }
    };
}
 
源代码30 项目: webrtc-java   文件: LanternRTC.java
public void waitDelaysFinish() {
    try {
        Thread.sleep(100);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
 
 类所在包
 同包方法