Is thread safe??


Performance and scalability: Is thread safe??

  1. Is thread safe?? (4 messages)

    I am using the to get the connection to the database. Depend on the input parameter I am getting the result.
    Query : if more than one person get the connection with using and sends their inputs at the same time, will they get their respective results. ie, to say is the connection is thread safe??
    Please suggest.

    Threaded Messages (4)

  2. please elaborate[ Go to top ]

    How are you using the HTTPUrlConnection to get a database connection? Please paste code.
  3. Here is code....[ Go to top ]

    Thanks for the reply, Osullivan.
    Here is the code. Please let me know if you need any more information.

            String myResp="";
            BufferedReader br=null;
            String myquery= "";

           try {

             url = form the url
    //( ie. url = new URL("http://"+Server_name":"+other information);

        con = (HttpURLConnection)url.openConnection();
     if (con.getResponseCode()==HttpURLConnection.HTTP_OK)
         br= new BufferedReader(new InputStreamReader con.getInputStream()));
         String tmp = br.readLine();
        ...... // populate the response to the data beans.
      }catch (Exception e) {
      }finally {

  4. Hmm[ Go to top ]

    Hi Madhu,

    Ok I understand what you are doing now.

    I guess the question is really whether URLConnection.connect() is threadsafe, as that is the one that issues the HTTP request. Clearly each of your clients is running as a discreet process, so they don't share any memory segments. So there is not need to worry about thread safety among clients.

    So the only other worry would be whether client requests and handled with thread safety on the server. This depends on the database implementation you are using to handle the incoming HTTP requests.

    If it is a vendor product, such as Mod-PL/SQL, it can be assumed to be thread-safe in this respect, otherwise it would not be fit for purpose!

    If you have developed your own HTTP broker for the database, this may well thread unsafe, for example if you are using Servlets with member variables.
  5. regarding HtpURLConnection[ Go to top ]

    Thanks for your detailed information, Osullivan.