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:

  1. android: execute code in regular intervals
  2. use countdowntimer countdowntimer executes in main thread (if want)
  3. or use timertask.

my suggestion case option 1 or 3.

-v


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -