zoukankan      html  css  js  c++  java
  • Java:小问题集锦

    问题一:

    当我们在使用DefaultHttpClient进行Http网络请求的时候,你会发现开启多个线程进行请求会有阻塞的问题出现。

    解决方法:(通过Java的线程阻塞处理synchronized)

            synchronized (client) {
                HttpResponse httpResponse = client.execute(request);
                int statusCode = httpResponse.getStatusLine().getStatusCode();
                LogUtil.info(TAG, "statusCode= " + statusCode);
                if (HttpStatus.SC_OK == statusCode) {
                    String result = EntityUtils.toString(httpResponse.getEntity());
                    httpResponse.getEntity().consumeContent();
                    request.abort();
                    return result;
                }
                request.abort();
            }

    问题二:

    4.0的系统 ListView在没有setAdapter之前 removeView是没有问题的

    在2.2/2.3的系统中 则应该先setAdapter再进行remove操作

  • 相关阅读:
    设计模式
    工厂方法模式
    简单工厂模式
    tornado自定义Form组件
    tornado
    Tornado框架的知识系列
    Linux基本命令
    day2
    day1
    使用cp复制文件夹却不能打开
  • 原文地址:https://www.cnblogs.com/gongcb/p/2955457.html
Copyright © 2011-2022 走看看