Results 1 to 3 of 3
  1. #1
    arnab321 is offline Member
    Join Date
    Oct 2008
    Posts
    40
    Rep Power
    0

    Arrow forcibly terminating io operations

    in the thread, if a connection is made with the http server, it takes too long at this line. how do i implement the "cancel connection" feature found in many j2me apps?

    int resc=hcon.getResponseCode();

    but calling thread.interrupt() during this wait does not terminate the operation.

    i hv a thread like this

    class thread extends Thread{
    ....
    public void run(){
    http();
    }
    public void http() throws IOException{
    ...make hcon a connection
    int resc=hcon.getResponseCode();
    System.out.println("a");
    }
    }






    and calling it like this:
    thread a=new thread();
    a.start();
    ....when reqd., a.interrupt() is called. but it does not print "a".keeps on waiting

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Smile set Daemon

    The only solution I have found to this problem ( which I have not tried ) is:
    Java Code:
    class TerminatableConnector extends Thread
    {
       // code....
    }
    main()
    {
      TerminatableConnector tc = new TerminatableConnector();
      tc.setDaemon(true);
    }
    Which places this thread at the mercy of main and other threads. The Thread class has some sort of done() which can be polled in a lower priority thread. I did a great deal of convoluted experimenting on this with my first project and found that this approach brings responsiveness within reason.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  3. #3
    arnab321 is offline Member
    Join Date
    Oct 2008
    Posts
    40
    Rep Power
    0

    Default

    hey, i dont think MIDP 2.0 supports the setDaemon() method, does it?

Similar Threads

  1. Illegal Arithmetic Operations?
    By Cruor in forum New To Java
    Replies: 13
    Last Post: 09-19-2008, 04:46 PM
  2. Stack push/pop/peek operations
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-29-2008, 09:03 AM
  3. String operations..
    By sireesha in forum New To Java
    Replies: 4
    Last Post: 12-14-2007, 02:04 AM
  4. Uses unchecked or unsafe operations message
    By Robbinz in forum New To Java
    Replies: 2
    Last Post: 12-06-2007, 10:56 PM
  5. terminating a while loop with a string
    By tkdvipers in forum New To Java
    Replies: 3
    Last Post: 07-09-2007, 11:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •