protected void closeWebDriver(Thread thread) { ALL_WEB_DRIVERS_THREADS.remove(thread); WebDriver webdriver = THREAD_WEB_DRIVER.remove(thread.getId()); if (webdriver != null && !holdBrowserOpen) { log.info("Close webdriver: " + thread.getId() + " -> " + webdriver); long start = System.currentTimeMillis(); Thread t = new Thread(new CloseBrowser(webdriver)); t.setDaemon(true); t.start(); try { t.join(closeBrowserTimeoutMs); } catch (InterruptedException e) { log.log(FINE, "Failed to close webdriver in " + closeBrowserTimeoutMs + " milliseconds", e); } long duration = System.currentTimeMillis() - start; if (duration >= closeBrowserTimeoutMs) { log.severe("Failed to close webdriver in " + closeBrowserTimeoutMs + " milliseconds"); } else if (duration > 200) { log.info("Closed webdriver in " + duration + " ms"); } else { log.fine("Closed webdriver in " + duration + " ms"); } } }
public void test(TestHarness th) { Thread notifyThreadArray = new NotifyThreadArray(); notifyThreadArray.start(); try { synchronized (a) { while (!done) { a.wait(); } } notifyThreadArray.join(); } catch (InterruptedException e) { th.fail("Unexpected exception: " + e); } done = false; Thread notifyThreadMultiArray = new NotifyThreadMultiArray(); notifyThreadMultiArray.start(); try { synchronized (b) { while (!done) { b.wait(); } } notifyThreadMultiArray.join(); } catch (InterruptedException e) { th.fail("Unexpected exception: " + e); } th.check(true); }
public static void main(String... args) { final PrintManager printManager = new PrintManager(); final Thread consumer = new Thread( new Runnable() { public void run() { int count = 0; while (count++ < 25) { try { sleep(nextInt(1000)); yield(); } catch (InterruptedException e) { e .printStackTrace(); // To change body of catch statement use File | Settings // | File Templates. } printManager.printMessage(); } } }, "consumerThread"); Thread producer = new Thread( new Runnable() { public void run() { int count = 0; while (count < 25) { try { sleep(nextInt(1000)); yield(); } catch (InterruptedException e) { e .printStackTrace(); // To change body of catch statement use File | Settings // | File Templates. } printManager.spoolMessage(format("printout%s", ++count)); } // System.out.println("Printing finished, interrupting // consumers..."); // consumer.interrupt(); } }, "producerThread"); consumer.start(); producer.start(); }
@Override public void actionPerformed(ActionEvent e) { // 对用户不同的选择做出不同的处理 if (e.getActionCommand().equals("new game")) { // 创建游戏界面面板 mp = new MyPanel("newGame"); // 启动MyPanel线程 Thread t = new Thread(mp); t.start(); // 先删除旧Panel this.remove(msp); this.add(mp); // 注册监听 this.addKeyListener(mp); // 显示(刷新JFrame) this.setVisible(true); } else if (e.getActionCommand().equals("exit")) { // 用户点击了退出系统菜单 // 保存击毁敌人数量. Recorder.SaveRecord(); System.exit(0); } // 对存盘退出做处理 else if (e.getActionCommand().equals("saveExit")) { Recorder rd = new Recorder(); rd.setEts(mp.enemyTanks); // 保存击毁敌人的数量和敌人的坐标 rd.SaveRecAndEnemy(); // 退出(0代表正常退出,1代表异常退出) System.exit(0); } else if (e.getActionCommand().equals("continue")) { // // 创建游戏界面面板 mp = new MyPanel("con"); // mp.flag="con"; // 启动MyPanel线程 Thread t = new Thread(mp); t.start(); // 先删除旧Panel this.remove(msp); this.add(mp); // 注册监听 this.addKeyListener(mp); // 显示(刷新JFrame) this.setVisible(true); } }
// public void FinalPatientInvoicePdf(java.sql.Connection connDb, java.lang.String begindate, // java.lang.String endate, java.lang.String combox) { public void NHIFStatementAccPdf( java.sql.Connection connDb, java.util.Date begindate, java.util.Date endate, java.lang.String combox, java.lang.String combox1) { dbObject = new com.afrisoftech.lib.DBObject(); memNo1 = combox1; connectDB = connDb; beginDate = begindate; endDate = endate; System.out.println("Days Date" + endDate); ageingSeries = new com.afrisoftech.timeseries.AgeingSeries(4, endate); // periodicDates = new com.afrisoftech.lib.PeriodicDates(endDate, 3); threadSample = new java.lang.Thread(this, "SampleThread"); System.out.println("threadSample created"); threadSample.start(); System.out.println("threadSample fired"); }
public void testListenerDoesntDeadlockOnStopAndWaitFromTerminated() throws Exception { final NoOpThreadedService service = new NoOpThreadedService(); service.addListener( new Listener() { @Override public void starting() {} @Override public void running() {} @Override public void stopping(State from) {} @Override public void terminated(State from) { service.stopAndWait(); } @Override public void failed(State from, Throwable failure) {} }, MoreExecutors.sameThreadExecutor()); service.startAndWait(); Thread thread = new Thread() { @Override public void run() { service.stopAndWait(); } }; thread.start(); thread.join(100); assertFalse(thread + " is deadlocked", thread.isAlive()); }
public static void main(String[] args) throws InterruptedException, IOException { System.setProperty("java.net.preferIPv4Stack", "true"); TransactionProcessor transProcessor = new TransactionProcessor(); transProcessor.getId(); System.out.println( "Transaction Processor id " + transProcessor.id + " waiting to be activated"); new Thread() { public void run() { for (int i = 0; i < 4; i++) { transProcessor.updatePeers(transProcessor.id, 0); try { sleep(peersUpdateInterval); } catch (InterruptedException ex) { Logger.getLogger(TransactionProcessor.class.getName()).log(Level.SEVERE, null, ex); } } } }.start(); transProcessor.listenMulticast(); Thread t = new Thread(transProcessor); t.setUncaughtExceptionHandler(transProcessor.h); t.start(); while (true) { transProcessor.sendAliveSignal(); Thread.sleep(transProcessor.sendingInverval); } }
public void TransByAccountPdf1( java.sql.Connection connDb, java.util.Date begindate, java.util.Date endate, java.lang.String combox, java.lang.String ptype) { bank = combox; paType = ptype; connectDB = connDb; beginDate = begindate; endDate = endate; threadSample = new java.lang.Thread(this, "SampleThread"); System.out.println("threadSample created"); threadSample.start(); System.out.println("threadSample fired"); dbObject = new com.afrisoftech.lib.DBObject(); }
public void ReceiptsRtf( java.sql.Connection connDb, java.lang.String combox, java.lang.String name, java.lang.String amount, java.lang.String receipt, java.lang.String paymode) { MNo = combox; Name = name; Amount = amount; Receipt = receipt; connectDB = connDb; Paymode = paymode; // beginDate = begindate; // endDate = endate; threadSample = new java.lang.Thread(this, "SampleThread"); System.out.println("threadSample created"); threadSample.start(); System.out.println("threadSample fired"); }
/** * Initialize the updater * * @param plugin The plugin that is checking for an update. * @param slug The dev.bukkit.org slug of the project * (http://dev.bukkit.org/server-mods/SLUG_IS_HERE) * @param file The file that the plugin is running from, get this by doing this.getFile() from * within your main class. * @param type Specify the type of update this will be. See {@link UpdateType} * @param announce True if the program should announce the progress of new updates in console */ public Updater(Plugin plugin, String slug, File file, UpdateType type, boolean announce) { this.plugin = plugin; this.type = type; this.announce = announce; this.file = file; try { // Obtain the results of the project's file feed url = new URL(DBOUrl + slug + "/files.rss"); } catch (MalformedURLException ex) { // Invalid slug plugin .getLogger() .warning( "The author of this plugin (" + plugin.getDescription().getAuthors().get(0) + ") has misconfigured their Auto Update system"); plugin .getLogger() .warning( "The project slug given ('" + slug + "') is invalid. Please nag the author about this."); result = Updater.UpdateResult.FAIL_BADSLUG; // Bad slug! Bad! } thread = new Thread(new UpdateRunnable()); thread.start(); }
/** begin displaying the message */ public void begin() { g2d.clearAll = false; g2d.paintAll = false; super.start(); }
public void SalesReportPdf( java.sql.Connection connDb, java.util.Date begindate, java.util.Date endate, java.lang.String cashPoint, java.lang.String glAccount) { connectDB = connDb; beginDate = begindate; endDate = endate; CashPoint = cashPoint; gAccount = glAccount; dbObject = new com.afrisoftech.lib.DBObject(); threadSample = new java.lang.Thread(this, "SampleThread"); System.out.println("threadSample created"); threadSample.start(); System.out.println("threadSample fired"); }
// public void FinalPatientInvoicePdf(java.sql.Connection connDb, java.lang.String begindate, // java.lang.String endate, java.lang.String combox) { public void StatementAccDetailPdf( java.sql.Connection connDb, java.util.Date begindate, java.util.Date endate, java.lang.String combox1, java.lang.String combox) { dbObject = new com.afrisoftech.lib.DBObject(); memNo1 = combox1; memNo = combox; connectDB = connDb; beginDate = begindate; endDate = endate; threadSample = new java.lang.Thread(this, "SampleThread"); System.out.println("threadSample created"); threadSample.start(); System.out.println("threadSample fired"); }
public void RevenuePriceListPdf( java.sql.Connection connDb, java.util.Date begindate, java.util.Date endate, java.lang.String combox) { // public void StoresBalPdf(java.sql.Connection connDb) { dbObject = new com.afrisoftech.lib.DBObject(); bank = combox; connectDB = connDb; // beginDate = begindate; // endDate = endate; threadSample = new java.lang.Thread(this, "SampleThread"); System.out.println("threadSample created"); threadSample.start(); System.out.println("threadSample fired"); }
@Test public void shouldAllowTwoInstancesOfFirefoxAtTheSameTimeInDifferentThreads() throws InterruptedException { class FirefoxRunner implements Runnable { private volatile WebDriver myDriver; private final String url; public FirefoxRunner(String url) { this.url = url; } public void run() { myDriver = newFirefoxDriver(); myDriver.get(url); } public void quit() { if (myDriver != null) { myDriver.quit(); } } public void assertOnRightPage() { assertEquals(url, myDriver.getCurrentUrl()); } } FirefoxRunner runnable1 = new FirefoxRunner(pages.formPage); Thread thread1 = new Thread(runnable1); // Thread safety reviewed FirefoxRunner runnable2 = new FirefoxRunner(pages.xhtmlTestPage); Thread thread2 = new Thread(runnable2); // Thread safety reviewed try { thread1.start(); thread2.start(); thread1.join(); thread2.join(); runnable1.assertOnRightPage(); runnable1.assertOnRightPage(); } finally { runnable1.quit(); runnable2.quit(); } }
@Override public void start() { Log.d(MeerkatApplication.TAG, "\tAbstractPeriodicDataSource.start"); mRun = true; mTickLock = false; mThread = new Thread(this); mThread.start(); }
public synchronized void start() { if (thread != null) { throw new IllegalStateException("already running"); } thread = new Thread(ThreadGroup.systemThreadGroup, this, getClass().getSimpleName()); thread.setDaemon(true); thread.start(); }
public Bomb(int p, int range, int time, int x, int y) { bombRange = range; gridXPos = x; gridYPos = y; player = p; Bomberman.grid[gridXPos][gridYPos] = 5; bombThread = new Thread(this, "bombThread"); bombThread.start(); }
public BackDrop() { // one.go(); runner = new Thread(this, "two"); runner.start(); // Timer t=new Timer(15,this); // t.start(); for (int ctr = 0; ctr < rs.length; ctr++) { rs[ctr] = new Rock(0, 0, "images/tinyrock.png"); } }
// Called when the surface is resized public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { // Log.v("SDL", "surfaceChanged()"); int sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 by default switch (format) { case PixelFormat.A_8: Log.v("SDL", "pixel format A_8"); break; case PixelFormat.LA_88: Log.v("SDL", "pixel format LA_88"); break; case PixelFormat.L_8: Log.v("SDL", "pixel format L_8"); break; case PixelFormat.RGBA_4444: Log.v("SDL", "pixel format RGBA_4444"); sdlFormat = 0x85421002; // SDL_PIXELFORMAT_RGBA4444 break; case PixelFormat.RGBA_5551: Log.v("SDL", "pixel format RGBA_5551"); sdlFormat = 0x85441002; // SDL_PIXELFORMAT_RGBA5551 break; case PixelFormat.RGBA_8888: Log.v("SDL", "pixel format RGBA_8888"); sdlFormat = 0x86462004; // SDL_PIXELFORMAT_RGBA8888 break; case PixelFormat.RGBX_8888: Log.v("SDL", "pixel format RGBX_8888"); sdlFormat = 0x86262004; // SDL_PIXELFORMAT_RGBX8888 break; case PixelFormat.RGB_332: Log.v("SDL", "pixel format RGB_332"); sdlFormat = 0x84110801; // SDL_PIXELFORMAT_RGB332 break; case PixelFormat.RGB_565: Log.v("SDL", "pixel format RGB_565"); sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 break; case PixelFormat.RGB_888: Log.v("SDL", "pixel format RGB_888"); // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead? sdlFormat = 0x86161804; // SDL_PIXELFORMAT_RGB888 break; default: Log.v("SDL", "pixel format unknown " + format); break; } SDLActivity.onNativeResize(width, height, sdlFormat); // Now start up the C app thread if (mSDLThread == null) { mSDLThread = new Thread(new SDLMain(), "SDLThread"); mSDLThread.start(); } }
public Bomb(int p, int range) { bombRange = range; player = p; delay = 3000; gridXPos = Bomberman.player[player].getGridXPos(); gridYPos = Bomberman.player[player].getGridYPos(); System.out.println(gridXPos + "," + gridYPos); Bomberman.grid[gridXPos][gridYPos] = 5; bombThread = new Thread(this, "bombThread"); bombThread.start(); }
private void invokeOnExecutionThreadForTest(Runnable runnable) { executionThread = new Thread(runnable); executionThread.setUncaughtExceptionHandler( new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable e) { thrownByExecutionThread = e; } }); executionThread.start(); }
@Override public void evaluate() throws Throwable { Runnable callSystemExit = new Runnable() { public void run() { System.exit(ARBITRARY_EXIT_STATUS); } }; Thread thread = new Thread(callSystemExit); thread.start(); sleep(1000); // wait until the thread exits }
public GameOfLife1(int w, int h) { height = h; width = w; newUniverse = new int[height][width]; oldUniverse = new int[height][width]; changed = new Vector(); runTest = true; bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); initValues(); th = new Thread(this); th.start(); }
public void test(TestHarness th) { try { Thread t = new RuntimeExceptionThread(); t.start(); t.join(); result = true; } catch (InterruptedException e) { th.fail("unexpected InterruptedException"); } th.check(result); }
/** Creates a new instance of Remindable */ public Remindable(java.sql.Connection connDB) { java.lang.Thread reminderThread = new java.lang.Thread(this, "Remindables.Thread"); connectDB = connDB; reminderContainer = new biz.systempartners.reminders.ReminderContainer(); defaultTip = this.getTipsArray(getListofReminders("SELECT * FROM xray")); reminderThread.start(); reminderContainer.showTipOfday(); }
public void CorporateTaxPdf( java.sql.Connection connDb, java.util.Date begindate, java.util.Date endate) { connectDB = connDb; beginDate = begindate; endDate = endate; threadSample = new java.lang.Thread(this, "SampleThread"); System.out.println("threadSample created"); threadSample.start(); System.out.println("threadSample fired"); }
public static void audioStartThread() { mAudioThread = new Thread( new Runnable() { public void run() { mAudioTrack.play(); nativeRunAudioThread(); } }); // I'd take REALTIME if I could get it! mAudioThread.setPriority(Thread.MAX_PRIORITY); mAudioThread.start(); }
public void RevenuesPdf(java.sql.Connection connDb) { connectDB = connDb; // beginDate = begindate; // endDate = endate; threadSample = new java.lang.Thread(this, "SampleThread"); System.out.println("threadSample created"); threadSample.start(); System.out.println("threadSample fired"); }
public void BalanceSheetPdf( java.sql.Connection connDb, java.lang.String begindate, java.lang.String endate) { connectDB = connDb; beginDate = begindate; endDate = endate; threadSample = new java.lang.Thread(this, "SampleThread"); System.out.println("threadSample created"); threadSample.start(); System.out.println("threadSample fired"); }