當前位置: 首頁>>代碼示例>>Java>>正文


Java Thread.run方法代碼示例

本文整理匯總了Java中java.lang.Thread.run方法的典型用法代碼示例。如果您正苦於以下問題:Java Thread.run方法的具體用法?Java Thread.run怎麽用?Java Thread.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.Thread的用法示例。


在下文中一共展示了Thread.run方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.lang.Thread; //導入方法依賴的package包/類
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.");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:DisplayChangeVITest.java

示例2: main

import java.lang.Thread; //導入方法依賴的package包/類
public static void main(String[] args)
{

  Thread t1 = new Thread(new Tuna("one"));
  Thread t2 = new Thread(new Tuna("two"));
  Thread t3 = new Thread(new Tuna("three"));
  Thread t4 = new Thread(new Tuna("four"));
  Thread t5 = new Thread(new Tuna("five"));
  Thread t6 = new Thread(new Tuna("six"));
  Thread t7 = new Thread(new Tuna("seven"));
  Thread t8 = new Thread(new Tuna("eight"));
  Thread t9 = new Thread(new Tuna("nine"));
  Thread t10 = new Thread(new Tuna("ten"));
  Thread t11 = new Thread(new Tuna("eleven"));
  Thread t12 = new Thread(new Tuna("twelve"));
  Thread t13 = new Thread(new Tuna("thirteen"));
  Thread t14 = new Thread(new Tuna("fourteen"));
  Thread t15 = new Thread(new Tuna("fifteen"));
  Thread t16 = new Thread(new Tuna("sixteen"));
  Thread t17 = new Thread(new Tuna("seventeen"));
  Thread t18 = new Thread(new Tuna("eighteen"));
  Thread t19 = new Thread(new Tuna("nineteen"));
  Thread t20 = new Thread(new Tuna("twenty"));
  Thread outraThread = new Thread();
  outraThread.run();

  /* This doesn't Works D=
  
  for(int i=1; i != 4; i++)
  {
  
    t(i).start();
  
  }*/
  t1.start();
  t2.start();
  t3.start();
  t4.start();
  t5.start();
  t6.start();
  t7.start();
  t8.start();
  t9.start();
  t10.start();
  t11.start();
  t12.start();
  t13.start();
  t14.start();
  t15.start();
  t16.start();
  t17.start();
  t18.start();
  t19.start();
  t20.start();
  
}
 
開發者ID:jozadaquebatista,項目名稱:JAVA-Overview,代碼行數:57,代碼來源:cThread3.java


注:本文中的java.lang.Thread.run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。