Java J2me多线程http数据从另一个线程泄漏

Java J2me多线程http数据从另一个线程泄漏,java,multithreading,http,java-me,Java,Multithreading,Http,Java Me,我需要在j2me设备上同时打开两个http连接。所以我在两个线程中打开了两个HttpConnection。但有时一个连接接收到另一个连接的数据。我如何解决这个问题? 我在诺基亚N70上测试该应用程序 代码很大。我试着写一些简单的伪代码 http.java: public class Http { public Http() { } public void start(String url) { new Thread() {

我需要在j2me设备上同时打开两个http连接。所以我在两个线程中打开了两个HttpConnection。但有时一个连接接收到另一个连接的数据。我如何解决这个问题?
我在诺基亚N70上测试该应用程序

代码很大。我试着写一些简单的伪代码

http.java:

public class Http
{
    public Http()
    {
    }

    public void start(String url) {
       new Thread() {
            public void run() {
                getHttp(url);
           }
       }.start();

    }

    private void getHttp(String url) {

        InputStream is = null;
        HttpConnection http=null ;
        try {
            http= (HttpConnection) Connector.open(url);

            httpCode = http.getResponseCode();
            is = http.openInputStream();
            int ic;
            byte[] tmp = new byte[1024];

            while (!cancel && (ic = is.read(tmp, 0, 1024)) != -1) {
                line.append((char) ic);
                bao.write(tmp, 0, ic);
                 }
              //httpnotify.receive(bao.toByteArray) ;
            } catch (Exception e) {
            }
        }

}
客户1:

Http http=new Http() ;
http.setNotify(self) ;
http.start("http://....") ;
客户2:

Http http2=new Http() ;
http2.setNotify(self) ;
http2.start("http://....") ;

我认为您需要在
getHttp()
方法上使用
synchronized
关键字,请告诉我们您是如何做到的。