if (executorService == null) {
executorService = Executors.newScheduledThreadPool(1);
executorService.scheduleAtFixedRate(new Runnable() {
public void run() {
try {
final NcsService ncsService = ncsUIService
.getNcsService();
List receivedMessages = ncsService.receivedMessages();
for (int i = 0, receivedMessagesSize = receivedMessages
.size(); i < receivedMessagesSize; i++) {
ncsUIService.addElementToReceiveTable(i,
receivedMessages.get(i));
}
if (receivedMessages.size() > 0) {
ncsService.updatePhoneView(phoneImageNumLabel,
phoneImageMessageLabel, receivedMessages
.get(receivedMessages.size() - 1));
}
} catch (Exception e) {
e.printStackTrace();