android 线程池的应用

来源:互联网 发布:可视化数据设计 编辑:程序博客网 时间:2024/05/29 15:20
1     ExecutorService executorService = Executors

            .newFixedThreadPool(threadCount + 1);

           // 线程池的创建服务器

           Runnable calculateBitmapWorker = new Runnable() {
                @Override
                public void run() {
                    Bitmap thumb = null;
                    try {
                        if (isThumbPath) {
                            thumb = BitmapFactory.decodeFile(thumbPath);
                            if (null == thumb) {
                                thumb = revitionImageSize(sourcePath);
                            }
                        } else {
                            thumb = revitionImageSize(sourcePath);
                        }
                    } catch (Exception e) {


                    }
                    if (null == thumb) {
                        thumb = PickPhotoActivity.bimap;
                    }
                    put(path, thumb);
                    final Bitmap bmpToCallback = thumb;
                    if (null != callback) {
                        handler.post(new Runnable() {
                            @Override
                            public void run() {
                                callback.imageLoad(iv, bmpToCallback, sourcePath);
                            }
                        });
                    }
                }
            };


            executorService.execute(calculateBitmapWorker);


0 0
原创粉丝点击