目录搜索
androidManifestManifest.permissionManifest.permission_groupandroid.accessibilityserviceAccessibilityServiceandroid.accountsAccountandroid.appNotificationManagerandroid.bluetoothBluetoothAdapterBluetoothClassBluetoothClass.DeviceBluetoothClass.Device.MajorBluetoothClass.ServiceBluetoothDeviceBluetoothServerSocketBluetoothSocketandroid.contentSharedPreferencesandroid.database.sqliteSQLiteCursorDriverSQLiteOpenHelperandroid.graphicsBitmapandroid.locationLocationListenerGeocoderGpsStatusGpsStatus.ListenerGpsStatus.NmeaListenerGpsSatelliteandroid.mediaAudioFormatAsyncPlayerAudioRecordAudioRecord.OnRecordPositionUpdateListenerThumbnailUtilsAudioManagerandroid.netTrafficStatsMailToLocalSocketandroid.osAsyncTaskAsyncTask.StatusCountDownTimerMessageMessageQueueHandlerThreadandroid.textHtmlandroid.utilJsonWriterandroid.viewContextMenuContextMenu.ContextMenuInfoDisplayViewManagerViewViewStubViewTreeObserverViewParentWindowManagerGestureDetectorGravityMenuInflaterScaleGestureDetectorSoundEffectConstantsandroid.view.inputmethodInputConnectionInputMethodInputMethodSessionBaseInputConnectionInputMethodManagerandroid.widgetAbsListViewAbsListView.LayoutParamsAbsListView.OnScrollListenerAbsListView.RecyclerListenerAbsoluteLayoutAbsoluteLayout.LayoutParamsAbsSeekBarAbsSpinnerAdapterViewAdapterView.AdapterContextMenuInfoAdapterView.OnItemLongClickListenerAdapterView.OnItemSelectedListenerAdapterView.OnItemClickListenerAnalogClockBaseAdapterBaseExpandableListAdapterButtonCheckBoxCheckedTextViewCheckableChronometerChronometer.OnChronometerTickListenerCompoundButtonCompoundButton.OnCheckedChangeListenerCursorAdapterCursorTreeAdapterDatePickerDatePicker.OnDateChangedListenerDialerFilterDigitalClockEditTextFilterFilter.FilterListenerFilter.FilterResultsExpandableListAdapterExpandableListView.OnChildClickListenerExpandableListView.OnGroupClickListenerExpandableListView.OnGroupCollapseListenerExpandableListView.OnGroupExpandListenerFilterableGalleryGallery.LayoutParamsGridViewGridLayoutGridLayout.AlignmentRadioGroupImageViewImageView.ScaleTypeHorizontalScrollViewImageButtonImageSwitcherFilterQueryProviderListAdapterListViewMediaControllerMultiAutoCompleteTextViewMultiAutoCompleteTextView.CommaTokenizerMultiAutoCompleteTextView.TokenizerQuickContactBadgeRadioButtonRatingBarRatingBar.OnRatingBarChangeListenerRelativeLayoutRemoteViewsResourceCursorAdapterResourceCursorTreeAdapterScrollerScrollViewSearchViewSearchView.OnCloseListenerSearchView.OnQueryTextListenerSearchView.OnSuggestionListenerSeekBarSeekBar.OnSeekBarChangeListenerSimpleAdapterSimpleAdapter.ViewBinderSimpleCursorAdapterSimpleCursorAdapter.CursorToStringConverterSimpleCursorAdapter.ViewBinderSimpleCursorTreeAdapterSimpleCursorTreeAdapter.ViewBinderSimpleExpandableListAdapterSlidingDrawerSlidingDrawer.OnDrawerCloseListenerSlidingDrawer.OnDrawerOpenListenerSlidingDrawer.OnDrawerScrollListenerSpinnerSpinnerAdapterWrapperListAdapterTabHostTabHost.TabSpecTextViewTimePickerTimePicker.OnTimeChangedListenerToastTableLayoutTableLayout.LayoutParamsTableRowTableRow.LayoutParamsTabWidgetTextSwitcherToggleButtonTwoLineListItemVideoViewViewAnimatorViewFlipperViewSwitcherViewSwitcher.ViewFactoryZoomButtonsControllerZoomButtonsController.OnZoomListenerZoomButtonZoomControlsdalvik.systemDexFile
文字


MessageQueue

译者微博:http://t.qq.com/strongxu

版本:Android 3.1 r1

 

结构

继承关系

public class MessageQueue extends Object

        

java.lang.Object

android.os.MessageQueue

 

类概述

保存消息列表的低级别类,这些消息由Looper对象派发。消息并不是直接添加到MessageQueue中的,而是通过与Looper对象关联的MessageQueue.IdleHandler对象添加的。

         调用Looper.myQueue方法可以获取当前线程的MessageQueue

 

公共方法

public final void addIdleHandler (MessageQueue.IdleHandler handler)

向消息队列中添加一个新的MessageQueue.IdleHandler。当调用IdleHandler.queueIdle()返回false时,此MessageQueue.IdleHandler会自动的从消息队列中移除。或者调用removeIdleHandler(MessageQueue.IdleHandler)也可以从消息队列中移除MessageQueue.IdleHandler

此方法是线程安全的。

         参数

                   handler              要添加的IdleHandler

 

public final void removeIdleHandler (MessageQueue.IdleHandler handler)

         从队列中移除之前调用addIdlehandler(MessageQueue.IdleHandler)添加的MessageQueue.IdleHandler。如果handler不在当前的空闲列表,不做任何事。

                   参数

                            handler              要移除的IdleHandler

 

受保护方法

protected void finalize ()

         在对象被VM回收之前调用。只有当垃圾回收器检测到运行的所有线程都不再使用此对象时才会出现。

         在对象被垃圾回收之前,此方法可以用来释放系统资源或者做其他的清理工作。默认的此方法实现是空的,这也是VM所期望的,但是子类可以重写此方法。在此方法执行是抛出的未捕获异常会导致程序立即结束,否则则会忽略异常。

         注意,VM会保证任何对象的finalize方法最多调用一次,但是它不会保证何时(或者是否)会调用finalize。例如,对象Bfinalize方法可以推迟执行对象Afinalize,因此它会导致推迟回收A的内存空间。为了安全,使用ReferenceQueue,因为在垃圾回收时,它在VM处理引用的方式上提供了更多的控制方法。

 

补充

文章精选

android线程 Handler Message Queue AsyncTask线程模型

                   Android中的Handler, Looper, MessageQueueThread


上一篇:下一篇: