当前位置:操作系统 > 安卓/Android >>

android启动线程注意的问题

启动方法一:
 
 
private void startLoadBitmapThread(){ 
    (new ReadBitmapRunnable(this, this.getContentResolver())).run(); 

启动方法二:
 
 
private void startLoadBitmapThread(){ 
    Thread thread = new Thread(new ReadBitmapRunnable(this, this.getContentResolver()));  
        thread.start(); 

 
线程类: www.zzzyk.com
 
 
class ReadBitmapRunnable implements Runnable{ 
     
    private Activity mActivity; 
    private ContentResolver mContentResolver; 
    public ReadBitmapRunnable(Activity pActivity, ContentResolver pContentResolver){ 
        mActivity = pActivity; 
        mContentResolver = pContentResolver; 
    } 
     
    @Override 
    public void run() { 
        // TODO Auto-generated method stub 
        GinwaveDataSource.readAllAlbumPicture(mActivity, mContentResolver); 
        GinwaveDataSource.readAllWhiteAlbumPicture(mActivity, mContentResolver); 
    } 

 
使用方法一启动线程会阻塞主线程,而是用方法二不会阻塞主线程,两者的区别还没搞清楚。

摘自 xiaoxiaobian3310903的专栏
补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,