/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
		
	public static void main(String[] args) {
		
		final ActionInterrupt interromper = new ActionInterrupt();
		final ActionFlag flag = new ActionFlag();
		flag.start();
		interromper.start();
		
			try {
				Thread.sleep(333L);
				interromper.interrupt();
				flag.setStop();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
	}

	
	
	static class ActionInterrupt extends Thread{
		@Override
		public void run() {
			int pt = 0;
			try {
				while(true){
					System.out.println("ActionInterrupt {"+pt+"}");
					Thread.sleep(10L);
					pt++;
				}
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	static class ActionFlag extends Thread{
		private volatile boolean running = true;

		public void setStop() {
		    running = false;
		}
		
		@Override
		public void run() {
			int pt = 0;
			while(running){
				try {
					Thread.sleep(10L);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				System.out.println("ActionFlag["+pt+"]");
				pt++;
			}
		}
	}

}