Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Main {
    public static void main(String[] args) {
        int NTHREADS = 25;
        ExecutorService exec = Executors.newFixedThreadPool(NTHREADS);
        exec.submit(new MailConsumer());
        exec.submit(new MailProducer());
        System.out.println("inside main");
    }
}

class MailConsumer implements Runnable {
    @Override
    public void run() {
        while (true) {
            System.out.println("inside mail Consumer");
            System.out.println("Thread executing = " + Thread.currentThread().getName());
        }
    }
}

class MailProducer implements Runnable {
    @Override
    public void run() {
        while (true) {
            System.out.println("inside mail Producer");
            System.out.println("Thread executing = " + Thread.currentThread().getName());
        }
    }
}