Контроль потока извне 21 Сентябрь 2009 by admin·0 Comments Это показывает, советы структура нити, которые позволяют вам контролировать выполнение ими за пределами легко. public class TT extends Thread { static final int RUN = 0; static final int SUSPEND = 1; static final int STOP = 2; private int state = RUN; public synchronized void setState(int s) { state = s; if (s == RUN) notify(); } private boolean boolean checkState() { while (state == SUSPEND) { try { wait(); } catch (Exception e) {} } if (state == STOP) return false; return true; } public void run() { while true { doSomething(); if (!checkState()) break; } } other