Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





Java - Code Samples

 Sample 1. Code Sample / Example / Snippet of java.util.concurrent.ScheduledExecutorService

    public void postEvent(final String topic, Map<String, String> payload) {

final Map<String, String> eventPayload = new HashMap<>(payload);

for (final EventListener listener : m_listeners) {

ScheduledExecutorService executor = getExecutorService();

if (executor.isShutdown()) {

logWarning("Cannot post event, executor is shut down!");

return;

}

executor.submit(new Runnable() {

@Override

public void run() {

try {

listener.handle(topic, eventPayload);

}

catch (Exception e) {

logWarning("Exception while posting event", e);

}

}

});

}

}


   Like      Feedback      java.util.concurrent.ScheduledExecutorService



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner