How to implement thread timeout in J2ME?

I use Connectorin J2ME and found that sometimes it takes a very long time to send a request, and sometimes it can stop the whole process.
Therefore, I am trying to put the code associated with Connectorin the stream and try to set the timeout on the stream. But I found out that it is very difficult to do in J2ME because there is no in J2ME join(timeout).
Is there any way to do this? Or the best way to deal with network connectivity in J2ME?
Thank you very much in advance.

+3
source share
1 answer

You must use a combination of three mechanisms:

  • Connector.open() -.
  • Thread.sleep() Connection.close() , , Connector.open().
  • Thread.sleep() Thread.interrupt() , , Connector.open().

MIDP Connection.close() , . , .

Thread.interrupt() MIDP ( ) , .

+4

Source: https://habr.com/ru/post/1744472/


All Articles