• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris

Problem Using ScheduledThreadPoolExecutor

Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm coding a program which calls a servlet, gets Strings in return, and posts the Strings into an EditText.

The code works fine without using the ScheduledThreadPoolExecutor , but when I use it, debugging the servlet shows the request has arrived, and it returns a answer, yet the Android application never posts the String into the EditText.

I want the program to call the servlet every 1 second.
At the moment where the program needs to start polling, this code is activated:

Class data member :

private ScheduledThreadPoolExecutor timer = new ScheduledThreadPoolExecutor(1);

Code in class :

timer.scheduleAtFixedRate(new Runnable() {
public void run() {
try {
String[] recentEvents;
recentEvents = getAllEvents(); // Gets the strings from the servlet
if (recentEvents != null)
activateEvents(recentEvents); // Prints them to the EditText
} catch (IOException e) {
}, 100, 1000,TimeUnit.MILLISECONDS);
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
    Bookmark Topic Watch Topic
  • New Topic