chapter_005/src/main/java/ru/job4j/wait/EmailNotification.java
/**
     * Create threads and start them.
     *
     * @throws InterruptedException
     */
Create threads and start them.
Create threads and start them .
public void start() throws InterruptedException {
        for (int x = 0; x < this.users.size(); x++) {
            this.pool.submit(new Runnable() {
                @Override
                public void run() {
                    User us = null;
                    try {
                        us = users.poll(1000, TimeUnit.MILLISECONDS);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    if (us != null) {
                        emailTo(us);
                    }
                }
            });
        }
        this.pool.shutdown();
        this.pool.awaitTermination(1, TimeUnit.DAYS);
    }
public void start ( ) throws InterruptedException { for ( int x = 0 ; x < this . users . size ( ) ; x ++ ) { this . pool . submit ( new Runnable ( ) { @ Override public void run ( ) { User us = null ; try { us = users . poll ( 1000 , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } if ( us != null ) { emailTo ( us ) ; } } } ) ; } this . pool . shutdown ( ) ; this . pool . awaitTermination ( 1 , TimeUnit . DAYS ) ; }
Create threads and start them.
Create threads and start them .