• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
RefQueueWorker Class Reference

A worker thread for processing queued references. More...

Inherits Runnable.

Description

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.

Notice

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...
 

Constructor & Destructor Documentation

◆ RefQueueWorker()

RefQueueWorker ( ReferenceQueue<?>  queue,
RefQueueHandler  handler 
)
Parameters
queuethe queue on which to wait for references
handlerthe handler to pass the references to

Member Function Documentation

◆ run()

void run ( )

If initialization succeeds, this method will only return after shutdown() . Only one thread can execute the main loop at any time.

◆ shutdown()

void shutdown ( )

It can be re-started afterwards by another call to run().

◆ toString()

String toString ( )
Returns
a descriptive string for this worker

Member Data Documentation

◆ refQueue

final ReferenceQueue<?> refQueue
protected

◆ refHandler

final RefQueueHandler refHandler
protected

◆ workerThread

volatile Thread workerThread
protected

This attribute is also used as a shutdown indicator.