List of usage examples for java.lang Thread start
public synchronized void start()
From source file:CustomEventPanel.java
public TimerComponent(int i) { interval = i;/*from w w w. ja va 2s . c o m*/ Thread t = new Thread(this); t.start(); evtq = Toolkit.getDefaultToolkit().getSystemEventQueue(); enableEvents(0); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start(); Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start();// w w w .j a v a2s. c om }
From source file:lcmc.LCMC.java
/** Cleanup before closing. */ public static void cleanupBeforeClosing() { final Thread t = new Thread(new Runnable() { @Override/*from w w w . j av a2s . c o m*/ public void run() { // TODO: don't try to reconnect when exiting System.out.println("saving..."); for (int i = 0; i < 10; i++) { System.out.println("."); System.out.flush(); Tools.sleep(2000); } System.out.println(); System.out.println("force exit."); System.exit(5); } }); t.start(); Tools.getGUIData().getMainFrame().setVisible(false); final String saveFile = Tools.getConfigData().getSaveFile(); Tools.save(saveFile, false); Tools.getConfigData().disconnectAllHosts(); }
From source file:Hypnosis1.java
public Hypnosis1(int numberOfSegments) { int numberOfCoordinates = numberOfSegments * 4 + 2; coordinates = new int[numberOfCoordinates]; deltas = new int[numberOfCoordinates]; for (int i = 0; i < numberOfCoordinates; i++) { coordinates[i] = (int) (Math.random() * 300); deltas[i] = (int) (Math.random() * 4 + 3); if (deltas[i] > 4) deltas[i] = -(deltas[i] - 3); }/*from w w w . j a va2 s. c o m*/ paint = new GradientPaint(0, 0, Color.blue, 20, 10, Color.red, true); Thread t = new Thread(this); t.start(); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start(); Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start();// ww w. jav a2 s . c o m System.out.println("Active group(child) threads in \"" + pGroup.getName() + "\" = " + pGroup.activeCount()); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start(); Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start();/*from www.j a v a2 s . com*/ System.out.println("ParentThreadGroup for " + pGroup.getName() + " is " + pGroup.getParent().getName()); System.out.println("ParentThreadGroup for " + cGroup.getName() + " is " + cGroup.getParent().getName()); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); int i = pGroup.getMaxPriority(); System.out.println("Maximum priority of ParentThreadGroup =" + i); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start(); Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start();/*from w w w. jav a 2 s . co m*/ }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start(); Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start();/* w w w . ja va 2 s . c o m*/ ThreadGroup[] grpList = new ThreadGroup[pGroup.activeGroupCount()]; int count = pGroup.enumerate(grpList); for (int i = 0; i < count; i++) { System.out.println("ThreadGroup " + grpList[i].getName() + " found"); } }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start(); Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start();/*from w w w . j a v a2 s . co m*/ System.out.println("Active threads in \"" + pGroup.getName() + "\" = " + pGroup.activeCount()); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start(); Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start();//from w ww. ja v a 2 s. c om System.out.println("Active threads in " + pGroup.getName() + " = " + pGroup.activeCount()); System.out.println("Is " + pGroup.getName() + " a daemon ThreadGroup? " + pGroup.isDaemon()); System.out.println("Is " + cGroup.getName() + " a daemon ThreadGroup? " + cGroup.isDaemon()); }