import java.util.*;

class ThreadSleep extends Thread {
        ThreadSleep(String id) {
                super(id);
                start();
        }

        public void run() {

                try {
                        for (;;) {
                                System.out.println(getName() + ": mi addormento");
                                sleep(2000);
                                System.out.println(getName() + ": mi risveglio");
                        }
                } catch (InterruptedException e) {
                        System.out.println(getName() + ": muoio!");
                }
        }
}

class ProvaSleep {
        public static void main(String[] args) throws InterruptedException {
                ThreadSleep[] t = new ThreadSleep[10];

                for (int i = 0; i < 10; i++)
                        t[i] = new ThreadSleep("Thread " + i);
                Scanner s = new Scanner(System.in);
                try {
                        for (;;) {
                                int i = s.nextInt();
                                t[i].interrupt();
                        }
                } catch (NoSuchElementException e) {
                        System.out.println("Bye");
                }
        }
}
