Demo entry 6328604

Thread

   

Submitted by Erik-Olivier Riendeau on Nov 27, 2016 at 21:48
Language: Java. Code size: 467 Bytes.

private volatile static boolean thread_on = false;
public void run(){
    try {
        Thread.sleep(500);
    } catch (InterruptedException e1) { }
    while(true){
        while(thread_on){
        // do something
        }
    }
}
public static void pauseThread(){
    thread_on = false;
}
public static void resumeThread(){
    thread_on = true;
}
public void activateAnotherThread(){
    pauseThread;
    "OtherThread".resumeThread();
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).