Results 1 to 3 of 3
- 11-12-2008, 07:09 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 40
- Rep Power
- 0
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
- 11-15-2008, 03:56 PM #2
set Daemon
The only solution I have found to this problem ( which I have not tried ) is:
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.Java Code:class TerminatableConnector extends Thread { // code.... } main() { TerminatableConnector tc = new TerminatableConnector(); tc.setDaemon(true); }Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
- 11-15-2008, 08:51 PM #3
Member
- Join Date
- Oct 2008
- Posts
- 40
- Rep Power
- 0
Similar Threads
-
Illegal Arithmetic Operations?
By Cruor in forum New To JavaReplies: 13Last Post: 09-19-2008, 04:46 PM -
Stack push/pop/peek operations
By Java Tip in forum Java TipReplies: 0Last Post: 01-29-2008, 09:03 AM -
String operations..
By sireesha in forum New To JavaReplies: 4Last Post: 12-14-2007, 02:04 AM -
Uses unchecked or unsafe operations message
By Robbinz in forum New To JavaReplies: 2Last Post: 12-06-2007, 10:56 PM -
terminating a while loop with a string
By tkdvipers in forum New To JavaReplies: 3Last Post: 07-09-2007, 11:23 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks