暂停所有线程花费在

时间:2015-12-26 11:08:59

标签: java android android-asynctask http-get

我正在尝试使用以下代码从Android服务器获取图像(15张图像)。

使用以下代码调用AsynTask:

DownloadImageSequencially lmib = new DownloadImageSequencially(); Lmib.execute(SplitImages);

此处 SplitImages 是图片网址数组。

class DownloadImageSequencially extends AsyncTask<Object,Void,Void>
{

    @Override
    protected Void doInBackground(Object... param) {
        // TODO Auto-generated method stub

            for (int indx = 0; indx < SplitImages.length; indx++) {
                 downloadBitmap(SplitImages[indx],indx);
            }
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        Log.i("Async-Example", "onPostExecute Called");

            progressDialog.dismiss();
            defailtReviewCardInitialisation();
            reviewCardActions();
    }

    private void downloadBitmap(String url,int indx) {
        // initilize the default HTTP client object

        HttpClient client = new DefaultHttpClient();

        //forming a HttoGet request
        url = url.replace("\\","");
        url = url.replace("\"","");
        Log.e("url","url: "+url);
        final HttpGet getRequest = new HttpGet(url);
        Log.e("Masthan1","Masthan1");
        //HttpPost getRequest = new HttpPost(url);
        try {

            if (android.os.Build.VERSION.SDK_INT > 9) {
                StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
                StrictMode.setThreadPolicy(policy);
            }
            Log.e("Masthan2","Masthan2");
            HttpResponse response = client.execute(getRequest);
            Log.e("Masthan3","Masthan3");
            //check 200 OK for success
            final int statusCode = response.getStatusLine().getStatusCode();
            Log.e("Masthan4","Masthan4");
            if (statusCode != HttpStatus.SC_OK) {
                Log.w("ImageDownloader", "Error " + statusCode +
                        " while retrieving bitmap from " + url);

            }

            final HttpEntity entity = response.getEntity();
            Log.e("Masthan5","Masthan5");
            if (entity != null) {
                InputStream inputStream = null;
                try {
                    // getting contents from the stream
                    inputStream = entity.getContent();
                    Log.e("Masthan6","Masthan6");
                    // decoding stream data back into image Bitmap that android understands
                    bitmapArray[indx] =  BitmapFactory.decodeStream(inputStream);
                    Log.e("Masthan7","Masthan7");

                } finally {
                    Log.e("Masthan8","Masthan8");
                    if (inputStream != null) {
                        Log.e("Masthan9","Masthan9");
                        inputStream.close();
                        Log.e("Masthan10", "Masthan10");
                    }
                    entity.consumeContent();
                    Log.e("Masthan11", "Masthan11");
                }
            }
        } catch (Exception e) {
            // You Could provide a more explicit error message for IOException
            getRequest.abort();
            Log.e("ImageDownloader", "Something went wrong while" +
                    " retrieving bitmap from " + url + e.toString());
        }

    }
}

这是Android的logcat。

12-26 15:54:16.641    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/tasty1.jpg
12-26 15:54:16.641    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:16.642    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:16.657    1108-1124/com.revu.revu E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xabffce10
12-26 15:54:17.364    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:17.456    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:17.456    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:17.456    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:17.781    1108-1120/com.revu.revu I/art﹕ Background sticky concurrent mark sweep GC freed 2602(245KB) AllocSpace objects, 1(20KB) LOS objects, 0% free, 29MB/29MB, paused 3.732ms total 226.124ms
12-26 15:54:18.282    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:18.282    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:18.283    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:18.283    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:18.283    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:18.283    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/healthy2.jpg
12-26 15:54:18.284    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:18.284    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:19.622    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:19.622    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:19.622    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:19.622    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:20.178    1108-1120/com.revu.revu I/art﹕ Clamp target GC heap from 32MB to 32MB
12-26 15:54:20.444    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 5.501ms
12-26 15:54:20.950    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 5.736ms
12-26 15:54:21.425    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:21.425    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:21.425    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:21.426    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:21.426    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:21.426    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/servedfresh3.jpg
12-26 15:54:21.426    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:21.426    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:21.720    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:21.720    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:21.720    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:21.720    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:21.724    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:21.724    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:21.724    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:21.724    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:21.724    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:21.724    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/valueformoney4.jpg
12-26 15:54:21.992    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 50.822ms
12-26 15:54:22.240    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:22.240    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:22.698    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:22.704    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:22.704    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:22.704    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:23.582    1108-1302/com.revu.revu I/art﹕ Starting a blocking GC Alloc
12-26 15:54:23.584    1108-1302/com.revu.revu I/art﹕ Starting a blocking GC Alloc
12-26 15:54:23.979    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 28.344ms
12-26 15:54:24.048    1108-1302/com.revu.revu W/art﹕ Suspending all threads took: 19.679ms
12-26 15:54:24.484    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 22.965ms
12-26 15:54:24.691    1108-1302/com.revu.revu I/art﹕ Alloc sticky concurrent mark sweep GC freed 909(43KB) AllocSpace objects, 1(20KB) LOS objects, 2% free, 31MB/32MB, paused 24.234ms total 814.957ms
12-26 15:54:24.791    1108-1302/com.revu.revu I/art﹕ Starting a blocking GC Alloc
12-26 15:54:24.939    1108-1302/com.revu.revu I/art﹕ Alloc partial concurrent mark sweep GC freed 4731(408KB) AllocSpace objects, 33(23MB) LOS objects, 22% free, 6MB/8MB, paused 3.352ms total 138.107ms
12-26 15:54:24.946    1108-1302/com.revu.revu W/art﹕ Suspending all threads took: 6.257ms
12-26 15:54:25.088    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 17.751ms
12-26 15:54:25.208    1108-1120/com.revu.revu I/art﹕ Background sticky concurrent mark sweep GC freed 21(800B) AllocSpace objects, 0(0B) LOS objects, 0% free, 11MB/11MB, paused 5.265ms total 255.262ms
12-26 15:54:25.464    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 15.615ms
12-26 15:54:25.478    1108-1120/com.revu.revu I/art﹕ Background partial concurrent mark sweep GC freed 138(40KB) AllocSpace objects, 0(0B) LOS objects, 14% free, 11MB/13MB, paused 4.739ms total 113.458ms
12-26 15:54:25.969    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 27.841ms
12-26 15:54:26.323    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:26.323    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:26.323    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:26.323    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:26.323    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:26.324    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/menuitemsareavailable_5.png
12-26 15:54:26.324    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:26.324    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:26.515    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:26.516    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:26.516    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:26.516    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:27.083    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:27.084    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:27.084    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:27.084    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:27.364    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:27.364    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/qualityofitemssufficient_6.png
12-26 15:54:27.664    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:27.727    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:28.036    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:28.036    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:28.036    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:28.036    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:28.329    1108-1120/com.revu.revu I/art﹕ Background sticky concurrent mark sweep GC freed 843(41KB) AllocSpace objects, 1(20KB) LOS objects, 0% free, 14MB/14MB, paused 3.906ms total 257.066ms
12-26 15:54:28.346    1108-1120/com.revu.revu W/art﹕ Suspending all threads took: 16.743ms
12-26 15:54:28.484    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 22.799ms
12-26 15:54:28.527    1108-1120/com.revu.revu I/art﹕ Background partial concurrent mark sweep GC freed 384(49KB) AllocSpace objects, 1(20KB) LOS objects, 12% free, 14MB/16MB, paused 4.480ms total 121.173ms
12-26 15:54:28.833    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:28.833    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:28.833    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:28.907    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:28.907    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:28.907    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/happywiththemenuplan_7.png
12-26 15:54:28.908    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:28.908    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:29.393    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:29.393    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:29.393    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:29.393    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:29.802    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:29.803    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:29.803    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:29.804    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:29.804    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:29.804    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/servesasperthescedule_8.png
12-26 15:54:29.804    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:29.804    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:31.052    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:31.052    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:31.052    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:31.052    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:31.346    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:31.346    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:31.347    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:31.347    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:31.347    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:31.347    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/serveshyginically_9.png
12-26 15:54:31.347    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:31.347    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:31.554    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 71.590ms
12-26 15:54:31.568    1108-1120/com.revu.revu I/art﹕ Background partial concurrent mark sweep GC freed 690(101KB) AllocSpace objects, 2(40KB) LOS objects, 10% free, 17MB/19MB, paused 3.661ms total 219.596ms
12-26 15:54:31.931    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:31.931    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:31.932    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:31.932    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:32.092    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:32.093    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:32.094    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:32.094    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:32.094    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:32.173    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/ishappytoserveme_10.png
12-26 15:54:32.173    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:32.173    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:32.834    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:32.834    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:32.834    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:32.916    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:33.021    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 33.575ms
12-26 15:54:33.060    1108-1120/com.revu.revu I/art﹕ Background sticky concurrent mark sweep GC freed 421(21KB) AllocSpace objects, 1(20KB) LOS objects, 0% free, 19MB/19MB, paused 4.151ms total 126.092ms
12-26 15:54:33.349    1108-1120/com.revu.revu I/art﹕ Background partial concurrent mark sweep GC freed 336(83KB) AllocSpace objects, 0(0B) LOS objects, 9% free, 19MB/21MB, paused 2.900ms total 229.586ms
12-26 15:54:33.483    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:33.483    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:33.483    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:33.483    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:33.483    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:33.483    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/approchableregardingmyconserns_11.png
12-26 15:54:33.484    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:33.484    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:33.512    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 11.051ms
12-26 15:54:34.084    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:34.084    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:34.146    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:34.147    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:34.428    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:34.429    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:34.429    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:34.429    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:34.429    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:34.429    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/behavesprofessional_12.png
12-26 15:54:34.430    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:34.430    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:35.129    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:35.129    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:35.129    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:35.129    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:35.258    1108-1120/com.revu.revu W/art﹕ Suspending all threads took: 5.540ms
12-26 15:54:35.558    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 47.962ms
12-26 15:54:35.656    1108-1120/com.revu.revu I/art﹕ Background partial concurrent mark sweep GC freed 363(48KB) AllocSpace objects, 1(20KB) LOS objects, 8% free, 22MB/24MB, paused 3.845ms total 387.375ms
12-26 15:54:35.663    1108-1120/com.revu.revu W/art﹕ Suspending all threads took: 6.837ms
12-26 15:54:35.770    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:35.770    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:35.770    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:35.770    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:35.770    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:35.771    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/ismaintainedcleanly_13.png
12-26 15:54:35.772    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:35.773    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:36.046    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 26.053ms
12-26 15:54:37.111    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:37.111    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:37.111    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:37.111    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:37.579    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:37.579    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:37.579    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:37.579    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:37.579    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:37.580    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/islargeenufftofitmein_14.png
12-26 15:54:37.580    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:37.580    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:37.982    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:37.982    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:37.983    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:37.983    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:39.240    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 44.131ms
12-26 15:54:39.269    1108-1120/com.revu.revu I/art﹕ Background sticky concurrent mark sweep GC freed 860(41KB) AllocSpace objects, 1(20KB) LOS objects, 0% free, 25MB/25MB, paused 19.100ms total 172.207ms
12-26 15:54:39.559    1108-1120/com.revu.revu I/art﹕ Background partial concurrent mark sweep GC freed 502(125KB) AllocSpace objects, 1(20KB) LOS objects, 7% free, 25MB/27MB, paused 2.951ms total 199.381ms
12-26 15:54:40.110    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:40.110    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:40.110    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:40.111    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:40.111    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11
12-26 15:54:40.111    1108-1302/com.revu.revu E/url﹕ url: http://10.0.2.2:80/revue/Images/ReviewCard/Student/ambienceisgoodforhavingfood_15.png
12-26 15:54:40.111    1108-1302/com.revu.revu E/Masthan1﹕ Masthan1
12-26 15:54:40.111    1108-1302/com.revu.revu E/Masthan2﹕ Masthan2
12-26 15:54:40.191    1108-1116/com.revu.revu W/art﹕ Suspending all threads took: 13.265ms
12-26 15:54:40.784    1108-1302/com.revu.revu E/Masthan3﹕ Masthan3
12-26 15:54:40.784    1108-1302/com.revu.revu E/Masthan4﹕ Masthan4
12-26 15:54:40.784    1108-1302/com.revu.revu E/Masthan5﹕ Masthan5
12-26 15:54:40.784    1108-1302/com.revu.revu E/Masthan6﹕ Masthan6
12-26 15:54:41.021    1108-1302/com.revu.revu E/Masthan7﹕ Masthan7
12-26 15:54:41.021    1108-1302/com.revu.revu E/Masthan8﹕ Masthan8
12-26 15:54:41.021    1108-1302/com.revu.revu E/Masthan9﹕ Masthan9
12-26 15:54:41.022    1108-1302/com.revu.revu E/Masthan10﹕ Masthan10
12-26 15:54:41.022    1108-1302/com.revu.revu E/Masthan11﹕ Masthan11

我观察到的是,当我们尝试在AsynTask中执行以下操作时,即使我在高速互联网或本地主机上工作,也需要花费大量时间(至少30秒)。

  1. Client.execute(调用getRequest);
  2. Entity.getContent();
  3. 请帮帮我,为什么需要时间?如果表现良好,你也可以建议我替代方法。

1 个答案:

答案 0 :(得分:0)

你正在使用单个asynctask线程下载多个文件..所以显然,如果文件数量很高,则需要更多时间..如果你想同时下载多个文件,那么尝试使用

http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html

请参阅: - java download multiple files using threads