I’m looking for a way to make a PacketCollector stop blocking after waiting on nextResult(). For example:
1 //some line before;
2 Packet packet = collector.nextResult();
3 //some line after;
How coluld I force PacketCollector to continue or throw an Exception or somthing when is blocked at line 2? I tried without luck with collector.clancel() and connection.close();
Maybe is not posible, should I use polling in that situation instead of blocking?
Thanks Op3racional. Yes, it’s done that way. The point is that its part of a servlet. In fact, nextResult() is implemented with a timeout of 2 minutes. I can operate all other things in other threads and its working fine. But when I want to shutdown the server, i have those threads waiting. The server dont wait so much and shutdowns abnormally. I was looking for a way to tell those threads to wait no more, so the server can go down normally. Am I missing something about Java threads here?
I was looking at the source of smack an finally I think there is no way to kill a blocking PacketCollector.nextResult() method without hacking it a little bit.