diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/runnable/EventLoggingTask.java b/core-java-concurrency/src/main/java/com/baeldung/concurrent/runnable/EventLoggingTask.java new file mode 100644 index 0000000000..d65f79202e --- /dev/null +++ b/core-java-concurrency/src/main/java/com/baeldung/concurrent/runnable/EventLoggingTask.java @@ -0,0 +1,17 @@ +package com.baeldung.concurrent.runnable; + + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EventLoggingTask implements Runnable{ + private Logger logger = LoggerFactory.getLogger(EventLoggingTask.class); + + @Override + public void run() { + + String messge="Message read from the event queue"; + logger.info("Message read from event queue is "+messge); + + } +} diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/runnable/TaskRunner.java b/core-java-concurrency/src/main/java/com/baeldung/concurrent/runnable/TaskRunner.java new file mode 100644 index 0000000000..8fd98e77b8 --- /dev/null +++ b/core-java-concurrency/src/main/java/com/baeldung/concurrent/runnable/TaskRunner.java @@ -0,0 +1,25 @@ +package com.baeldung.concurrent.runnable; + + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class TaskRunner { + + private static ExecutorService executorService; + + public static void main(String[] args) { + executeTask(); + } + + private static void executeTask() { + executorService= Executors.newSingleThreadExecutor(); + + EventLoggingTask task = new EventLoggingTask(); + + Future future = executorService.submit(task); + + executorService.shutdown(); + } +}