HTTP Request locks UI Thread

Version 1
    This document was generated from CDN thread

    Created by: Paul Volkaerts on 07-02-2012 09:01:27 AM
    Hi.
     
    We have discovered the following and would like to know if this is a bug that can be fixed, or is expected behaviour.  It seems that a HTTP request that takes a long time to receive a reply from the server locks the UI thread for that duration, even though the HTTP request is running in a background thread.
     
    To prove this we created a simple application that had a canvas and sent a HTTP in the background on a keypress as well as updating the screen.  What we see when the code below runs is that further keypresses do NOT update the display until the HTTP request is complete, at which point the buffered key presses are all executed.
     

        static boolean first=true;
        protected void keyPressed(int keyCode) {
     
            teststring += "1"; // This is just a string that is displayed in paint()
            if (first) {
                (new Thread() {
     
                    public void run() {
     
                        try {
                            int rc = 200;
                            HttpConnection hc = null;
     
                            String url = "http://192.168.0.203:8080/channels";
                            hc = (HttpConnection) Connector.open(url);
                            hc.setRequestMethod(HttpConnection.POST);
                            rc = hc.getResponseCode();
                        }
                        catch (Exception e) {  teststring = e.getMessage(); }
                    }
     
     
                }).start();
            }
            first = false;
     
            repaint();
     
        }

     
    Please let us know if this is expected behaviour and if not if it can be fixed.
     
    Thanks;
    Paul