2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.ddmuilib;
19 import com.android.ddmlib.Log;
22 * base background thread class. The class provides a synchronous quit method
23 * which sets a quitting flag to true. Inheriting classes should regularly test
24 * this flag with <code>isQuitting()</code> and should finish if the flag is
27 public abstract class BackgroundThread extends Thread {
28 private boolean mQuit = false;
31 * Tell the thread to exit. This is usually called from the UI thread. The
32 * call is synchronous and will only return once the thread has terminated
35 public final void quit() {
37 Log.d("ddms", "Waiting for BackgroundThread to quit");
40 } catch (InterruptedException ie) {
45 /** returns if the thread was asked to quit. */
46 protected final boolean isQuitting() {