public static void trigger() {
   syncInterrupt.lock();
   if (allowInterrupt) {
     myThread.interrupt();
   } else {
     triggered = true;
   }
   syncInterrupt.unlock();
 }
 public static void main(String[] args) {
   ThreadInterruptDemo test = new ThreadInterruptDemo();
   MyThread thread = test.new MyThread();
   thread.start();
   try {
     Thread.currentThread().sleep(2000);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   thread.interrupt();
 }
Exemple #3
0
 @Override
 public void surfaceDestroyed(SurfaceHolder holder) {
   mThread.interrupt();
 }