multithreading - Android recuring task best option? -
good morning everyone,
i sending data device android each 40ms. until now, have been using while(true) thread , thread.sleep because didn't know better :). see have lot of "better" options like:
timertask
asynctask
scheduledthreadpoolexecutor
which best 1 scenario? keep in mind there may exception thrown if device disconnects need stop sending values until connection restored. furthermore, data must sent @ pretty precise intervals , should, in no case, sent less 40ms before previous one.
thanks!
plenty of options, however, prior asynctask not belong list. asynctask used perform operation in background thread outside of main ui thread , not used scheduling repeating tasks.
for repeating tasks, options are:
- android: execute code in regular intervals
- use countdowntimer countdowntimer executes in main thread (if want)
- or use timertask.
my suggestion case option 1 or 3.
-v
Comments
Post a Comment