title: AsyncTask refreshing google map api v2
body: <p>My android application retrieves some json data from remote API for each Marker (a Marker shows the position of a real device, there are less than 10 devices to watch) present on the map, and sets status of a device by changing a color of the marker according to some rule working on a given json data. I use AsyncTask to fetch json data and change a status of a device. I keep fetched data in <code>ConcurrentHashMap&lt;Device, Data&gt;</code>. So, I run a number of asynctasks, one for each device. I also use a custom info window (in fact custom InfoWindowAdapter) to show some more data about device. First I draw a markers and keep them in a map <code>HashMap&lt;Device, Marker&gt;</code>. I execute asynctasks one by one using:</p>
  
  <pre><code>new MyAsyncTask(markerMap).execute(device)
  </code></pre>
  
  <p>My custom InfoWindowAdapter overrides getInfoContents method, where some collected by asynctasks data are used to be shown in InfoWindow, when clicked.
  Everything works fine. But now I want to refresh my markers every 10 sec. I have tried to do it using the following approach:</p>
  
  <pre><code>Timer timer = new Timer();
  
  timer.scheduleAtFixedRate(new TimerTask(){
  
      @Override
      public void run() {
  
          new MyAsyncTask(markerMap).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, device1);
          new MyAsyncTask(markerMap).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, device2);
  
      }}, 0, 10000);
  </code></pre>
  
  <p>My question is if it is the right/ best way to refresh my map? Or should I use Runnable instead of AsyncTask, and within a Runnable send a message to Handler when fetching json data to update Marker? One more question: should I use Timer or ScheduledExecutorService? I have read some StackOverflow discussions but I dont know the final recommendation. Thanks.</p>