Java Code Examples for android.os.HandlerThread#isAlive()

The following examples show how to use android.os.HandlerThread#isAlive() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkerHandler.java    From Lassi-Android with MIT License 6 votes vote down vote up
@NonNull
public static WorkerHandler get(@NonNull String name) {
    if (sCache.containsKey(name)) {
        WorkerHandler cached = sCache.get(name).get();
        if (cached != null) {
            HandlerThread thread = cached.mThread;
            if (thread.isAlive() && !thread.isInterrupted()) {
                LOG.w("get:", "Reusing cached worker handler.", name);
                return cached;
            }
        }
        LOG.w("get:", "Thread reference died, removing.", name);
        sCache.remove(name);
    }

    LOG.i("get:", "Creating new handler.", name);
    WorkerHandler handler = new WorkerHandler(name);
    sCache.put(name, new WeakReference<>(handler));
    return handler;
}
 
Example 2
Source File: a.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public a(int l, boolean flag, b b1, h h1)
{
    super(l, flag, b1);
    i = false;
    a(h1);
    e = new e();
    f = new e();
    g = e;
    h = f;
    d = new char[h1.f()];
    h1.b();
    h();
    j = new HandlerThread(h1.c(), h1.i());
    if (j != null)
    {
        j.start();
    }
    if (j.isAlive() && j.getLooper() != null)
    {
        k = new Handler(j.getLooper(), this);
    }
    f();
}
 
Example 3
Source File: DefaultLithoHandlerDynamicPriority.java    From litho with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link LithoHandler} instance backed by a {@link HandlerThread}. Starts the
 * HandlerThread if it's not started yet.
 */
public DefaultLithoHandlerDynamicPriority(HandlerThread handlerThread) {
  if (!handlerThread.isAlive()) {
    handlerThread.start();
  }

  mHandlerThread = handlerThread;
  mDelegate = new DefaultLithoHandler(handlerThread.getLooper());
}