List of usage examples for java.lang Thread Thread
public Thread(String name)
From source file:Main.java
public static void GetSUAccess() { Thread su = new Thread(new Thread() { public void run() { try { Log.i("SU", "Trying to grant access to port..."); Process suProcess = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(suProcess.getOutputStream()); if (null != os) { os.writeBytes("chmod 666 /dev/ttymxc1 \n"); os.flush();//w ww.j ava 2 s . c om } Log.i("SU", "Granted Access to Port"); } catch (IOException e) { Log.e("SU", "Grant SuperUser Access Failed"); } } }); su.start(); }
From source file:Main.java
public static <T> void runInThread(Consumer<T> consumer, T element) { Runnable runnable = () -> consumer.accept(element); new Thread(runnable).start(); }
From source file:Main.java
/** * this function work by permission.// ww w. j av a 2 s . c o m */ public static void pressHome() { new Thread(new Runnable() { @Override public void run() { Instrumentation m_Instrumentation = new Instrumentation(); m_Instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_HOME); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } m_Instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_HOME); } }).start(); }
From source file:Main.java
/** * Executes a runnable object in a new thread. * @param runnable The runnable object./* w ww.jav a2 s. c o m*/ */ public static void executeAsync(final Runnable runnable) { new Thread(runnable).start(); }
From source file:Main.java
public static void showToast(final String toast, final Context context) { new Thread(new Runnable() { @Override/*from w w w.j a v a 2s.com*/ public void run() { Looper.prepare(); Toast.makeText(context, toast, Toast.LENGTH_SHORT).show(); Looper.loop(); } }).start(); }
From source file:Main.java
/***/ public static Thread[] createThreads(Runnable runnable, int threadCount) { Thread[] ret = new Thread[threadCount]; for (int i = 0; i < threadCount; i++) { ret[i] = new Thread(runnable); }// w ww . java 2s. c o m return ret; }
From source file:Main.java
public synchronized static Thread CreateThread(Runnable run) { Thread thread = new Thread(run); threadlist.add(new WeakReference<>(thread)); return thread; }
From source file:Main.java
public static synchronized Thread createTrackThread(Runnable run) { Thread t = new Thread(run); threadList.add(new WeakReference<>(t)); return t;/*from www.j a v a2s . c o m*/ }
From source file:Main.java
/** * Make an asynchronous call in a separate thread. * @param call a {@link Runnable} to run in the thread. */// ww w.ja v a2s. c o m public static void runAsynchronously(final Runnable call) { Thread thread = new Thread(call); thread.start(); }
From source file:Main.java
/** * Starts the given {@link Runnable} tasks as daemons * /*w w w. j av a2 s.c om*/ * @param tasks */ public static void startDaemon(Runnable... tasks) { for (Runnable task : tasks) { Thread thread = new Thread(task); thread.setDaemon(true); thread.setPriority(Thread.NORM_PRIORITY); thread.start(); } }