| 117 | // This method will give the thread one second to |
| 118 | // exit and will abandon it after this time. |
| 119 | public void wait_thread_short() { |
| 120 | final int wait_millisecs = 5000; // max time that we will wait for thread to exit |
| 121 | Thread th = thread; |
| 122 | if (th != null) { |
| 123 | try { |
| 124 | th.join(wait_millisecs); |
| 125 | } |
| 126 | catch (InterruptedException e) { |
| 127 | } |
| 128 | |
| 129 | // thread failed to stop? |
| 130 | if (th.isAlive()) { |
| 131 | // abandon thread and deliver our own status object to instantiator. |
| 132 | ClientAPI_Status status = new ClientAPI_Status(); |
| 133 | status.setError(true); |
| 134 | status.setMessage("CORE_THREAD_ABANDONED"); |
| 135 | call_done(status); |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | // Wait for worker thread to complete; to stop thread, |
| 141 | // first call super stop() method then wait_thread(). |