Example usage for java.lang Thread Thread

List of usage examples for java.lang Thread Thread

Introduction

In this page you can find the example usage for java.lang Thread Thread.

Prototype

public Thread(String name) 

Source Link

Document

Allocates a new Thread object.

Usage

From source file:Main.java

public static void sendKeyDownUpSync(final int keyCode) {
    new Thread(new Runnable() {
        @Override//  ww w.ja v  a2 s.  co m
        public void run() {
            new Instrumentation().sendKeyDownUpSync(keyCode);
        }
    }).start();
}

From source file:Main.java

public static Thread start(Runnable action) {
    Thread thread = new Thread(action);
    thread.start();
    return thread;
}

From source file:Main.java

public static void doInBackground(final Runnable task) {
    new Thread(new Runnable() {
        @Override// w w w  .  j  a  v a 2s .  co m
        public void run() {
            android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
            task.run();
        }
    }).start();
}

From source file:Main.java

public static void volumeAdd() {
    new Thread(new Runnable() {
        @Override//  w  w  w . j  av  a 2 s . c  om
        public void run() {
            Instrumentation m_Instrumentation = new Instrumentation();
            m_Instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_VOLUME_UP);
        }
    }).start();
}

From source file:Main.java

public static Thread startDaemon(Runnable action) {
    Thread thread = new Thread(action);
    thread.setDaemon(true);//ww w . j  av a 2s .co  m
    thread.start();
    return thread;
}

From source file:Main.java

private static Thread startDaemonThread(Runnable runnable) {
    Thread result = new Thread(runnable);
    result.setDaemon(true);/* ww w .ja v  a  2s .  c  om*/
    result.start();
    return result;
}

From source file:Main.java

public static Thread newThread(String threadName, Runnable runnable) {

    Thread thread = new Thread(runnable);
    thread.setName(threadName);/*  ww  w.  j  a  v  a  2s  . c  o m*/
    return thread;
}

From source file:Main.java

public static Thread startLoopThread(final Runnable runnable, final long repeatInterval) {
    Thread thread = new Thread(new Runnable() {
        @Override// w  ww . ja v  a 2s .  co  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:Main.java

public static void runThreadUseInnerClass() {
    new Thread(new Runnable() {
        @Override/*  w ww  . ja v a  2 s.co m*/
        public void run() {
            System.out.println("");
        }
    }).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  va2 s .c  o m
        public void run() {
            Looper.prepare();
            //                Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
            Looper.loop();
        }
    }).start();
}