List of usage examples for java.lang Thread start
public synchronized void start()
From source file:com.zoterodroid.client.NetworkUtilities.java
/** * Executes the network requests on a separate thread. * // ww w . j a v a2s . c o m * @param runnable The runnable instance containing network mOperations to * be executed. */ public static Thread performOnBackgroundThread(final Runnable runnable) { final Thread t = new Thread() { @Override public void run() { try { runnable.run(); } finally { } } }; t.start(); return t; }
From source file:com.dotmarketing.servlets.taillog.Tailer.java
/** * Creates and starts a Tailer for the given file. * //from w ww. j av a2s .c om * @param file the file to follow. * @param listener the TailerListener to use. * @param delay the delay between checks of the file for new content in milliseconds. * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. * @return The new tailer */ public static Tailer create(File file, TailerListener listener, long delay, boolean end) { Tailer tailer = new Tailer(file, listener, delay, end); Thread thread = new Thread(tailer); thread.setDaemon(true); thread.start(); return tailer; }
From source file:net.cs76.projects.student10792819.DrawableManager.java
/** * Fetch drawable on thread. Fetches drawable on a separate thread. * * @param urlString the url string/*from w w w .j a va2 s . co m*/ * @param listingAdapter the listing adapter * @param thumbnailCache the image view * @param position the position */ public static void fetchDrawableOnThread(final String urlString, final ListingAdapter listingAdapter, final Drawable[] thumbnailCache, final int position) { if (drawableMap.containsKey(urlString)) { Drawable o = drawableMap.get(urlString).get(); if (o != null) { thumbnailCache[position] = o; listingAdapter.notifyDataSetChanged(); return; } } final Handler handler = new Handler() { @Override public void handleMessage(Message message) { thumbnailCache[position] = (Drawable) message.obj; listingAdapter.notifyDataSetChanged(); } }; Thread thread = new Thread() { @Override public void run() { Drawable drawable = fetchDrawable(urlString); Message message = handler.obtainMessage(1, drawable); handler.sendMessage(message); } }; thread.start(); }
From source file:end2endtests.runner.ProcessRunner.java
private static void redirectStream(final InputStream in, final OutputStream out) { Thread t = new Thread(new Runnable() { public void run() { try { IOUtils.copy(in, out);/*from w w w . j a v a 2 s. c om*/ } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(out); } } }); t.setDaemon(true); t.start(); }
From source file:fi.jumi.launcher.remote.ProcessStartingDaemonSummoner.java
private static void copyInBackground(@WillClose InputStream src, @WillClose OutputStream dest) { // TODO: after removing me, update also ReleasingResourcesTest Thread t = new Thread(() -> { try {/*ww w .j a v a2 s . co m*/ IOUtils.copy(src, dest); } catch (IOException e) { throw Boilerplate.rethrow(e); } finally { IOUtils.closeQuietly(src); IOUtils.closeQuietly(dest); } }, "Daemon Output Copier"); t.setDaemon(true); t.start(); }
From source file:co.paralleluniverse.fibers.dropwizard.FiberDropwizardTest.java
@BeforeClass public static void setUpClass() throws InterruptedException, IOException { Thread t = new Thread(new Runnable() { @Override/* w ww . j a v a 2 s . c o m*/ public void run() { try { new MyDropwizardApp() .run(new String[] { "server", Resources.getResource("server.yml").getPath() }); } catch (final Exception ignored) { } } }); t.setDaemon(true); t.start(); waitUrlAvailable(SERVER_BASE_URL); }
From source file:com.mindcognition.mindraider.tools.Checker.java
public static void checkAndFixRepositoryAsync() { Thread thread = new Thread() { public void run() { Checker.checkAndFixRepository(); }/* w w w. ja v a2 s . co m*/ }; thread.setDaemon(true); thread.start(); }
From source file:com.adobe.aem.demomachine.gui.AemDemoUtils.java
public static void antTarget(AemDemo aemDemo, String targetName) { String selectedDemoMachine = (String) aemDemo.getListDemoMachines().getSelectedValue(); if (Arrays.asList(AemDemoConstants.INSTANCE_ACTIONS).contains(targetName) && (selectedDemoMachine == null || selectedDemoMachine.toString().length() == 0)) { JOptionPane.showMessageDialog(null, "Please select a demo environment before running this command"); } else {/*from w w w .j av a2s .co m*/ // New ANT project AemDemoProject p = new AemDemoProject(aemDemo); if (selectedDemoMachine != null && selectedDemoMachine.length() > 0) p.setUserProperty("demo.build", selectedDemoMachine.toString()); // Make sure host name is there try { p.setUserProperty("demo.hostname", InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException ex) { logger.error(ex.getMessage()); } p.init(); ProjectHelper helper = ProjectHelper.getProjectHelper(); p.addReference("ant.projectHelper", helper); helper.parse(p, aemDemo.getBuildFile()); // Running the target name as a new Thread System.out.println("Running ANT target: " + targetName); Thread t = new Thread(new AemDemoRunnable(aemDemo, p, targetName)); t.start(); } }
From source file:Main.java
public static Thread startLoopThread(final Runnable runnable, final long repeatInterval) { Thread thread = new Thread(new Runnable() { @Override/*from w w w . j av a 2 s . c o m*/ public void run() { while (true) { runnable.run(); if (repeatInterval > 0) { try { Thread.sleep(repeatInterval); } catch (InterruptedException e) { // NOP } } } } }); thread.start(); return thread; }
From source file:ezbake.thrift.ThriftUtils.java
@VisibleForTesting public static TServer startHshaServer(TProcessor processor, int portNumber) throws Exception { final TNonblockingServerSocket socket = new TNonblockingServerSocket(portNumber); final THsHaServer.Args serverArgs = new THsHaServer.Args(socket); serverArgs.processor(processor);/*from w w w .j a v a2 s . c o m*/ serverArgs.inputProtocolFactory(new TCompactProtocol.Factory()); serverArgs.outputProtocolFactory(new TCompactProtocol.Factory()); final TServer server = new THsHaServer(serverArgs); final Thread t = new Thread(new Runnable() { @Override public void run() { server.serve(); } }); t.start(); return server; }