Thursday, February 20, 2014
Andorid which method can be implemented in other special threads continue to refer to the line after a timeout
If I have the following requirements:
The main thread going to get a version number on the network
final version = 0;
new Thread () {
public run ()
{
version = GetVersion () ;/ / here is get the online version number
}
}. Start ()
???? Continue
while waiting here at the end of the thread or timeout 5 secondsLog.d ("GetVersion", version + "");
-------------------------------------------
How to achieve
Thank you<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Get the version sent out after a good message, process the message with handler, execution Log.d this line.
5 seconds timeout with Timer to achieve
Reply:
It is activated and the timing query its state after 5 seconds
Reply:
Landlord timeout 5 seconds to continue meant: Restart thread gets version of it.
First, the handler to process the message;
Get written version of the thread class, and then create objects for easy destruction and restart this thread sent a message of success to get version 1;
Timing words are written in class, create an object with Theard.sleep on the line, when a message 2;
For message processing: the destruction of the timing thread execution Log.d;
Message 2 treatment: Destruction and reboot to get the thread version, destroy and restart the timer thread.
I hope useful
landlord
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment