A worker thread for processing queued references. More...
Inherits Runnable.
java.lang.ref.Reference can be java.lang.ref.ReferenceQueue automatically by the garbage collector. If that feature is used, a daemon thread should be executing this worker. It will pick up the queued references and pass them on to a handler for appropriate processing.
The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.
/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Public Member Functions | |
RefQueueWorker (ReferenceQueue<?> queue, RefQueueHandler handler) | |
Instantiates a new worker to listen for lost connections. More... | |
void | run () |
The main loop of this worker. More... | |
void | shutdown () |
Shuts down this worker. More... | |
String | toString () |
Obtains a description of this worker. More... | |
Protected Attributes | |
final ReferenceQueue<?> | refQueue |
The reference queue to monitor. More... | |
final RefQueueHandler | refHandler |
The handler for the references found. More... | |
volatile Thread | workerThread |
The thread executing this handler. More... | |
RefQueueWorker | ( | ReferenceQueue<?> | queue, |
RefQueueHandler | handler | ||
) |
queue | the queue on which to wait for references |
handler | the handler to pass the references to |
void run | ( | ) |
If initialization succeeds, this method will only return after shutdown() . Only one thread can execute the main loop at any time.
void shutdown | ( | ) |
It can be re-started afterwards by another call to run().
String toString | ( | ) |
|
protected |
|
protected |
|
protected |
This attribute is also used as a shutdown indicator.