//import java.awt.*;
//import javax.swing.*;
//import java.awt.event.*;
//
//class TimerRunnable implements Runnable
//{
// private JLabel timerLabel;
//
// public TimerRunnable(JLabel timerLabel)
// {
// this.timerLabel = timerLabel;
// }
//
// @Override
// public void run() {
// // TODO Auto-generated method stub
// int n = 0;
// while(true)
// {
// timerLabel.setText(Integer.toString(n));
// n++;
// try {
// Thread.sleep(1000);
// }
// catch (InterruptedException e) {
// // TODO: handle exception
// return;
// }
// }
// }
//}
//public class Main extends JFrame
//{
// private Thread th;
// public Main()
// {
// setTitle("ThreadInterruptex");
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Container c = getContentPane();
// c.setLayout(new FlowLayout());
//
// JLabel timerLabel = new JLabel();
// timerLabel.setFont(new Font("Gothic",Font.ITALIC,80));
//
// TimerRunnable runnable = new TimerRunnable(timerLabel);
// th = new Thread(runnable);
// c.add(timerLabel);
//
// JButton btn = new JButton("kill Timer");
// btn.addActionListener(new ActionListener() {
//
// @Override
// public void actionPerformed(ActionEvent e) {
// // TODO Auto-generated method stub
// th.interrupt();
// JButton btn = (JButton)e.getSource();
// btn.setEnabled(false);
// }
// });
// c.add(btn);
//
// setSize(300,170);
// setVisible(true);
//
// th.start();
// }
// public static void main(String[] args) {
// new Main();
// }
//}
//import java.awt.*;
//import javax.swing.*;
//
//class SharedBoard
//{
// private int sum = 0;
// synchronized public void add()
// {
// int n = sum;
// Thread.yield();
// n += 10;
// sum = n;
// System.out.println(Thread.currentThread().getName() + ":" + sum);
// }
// public int getSum()
// {
// return sum;
// }
//}
//
//class StudentThread extends Thread
//{
// private SharedBoard board;
//
// public StudentThread(String name, SharedBoard board)
// {
// super(name);
// this.board = board;
// }
// public void run()
// {
// for(int i = 0; i < 10; i++)
// {
// board.add();
// }
// }
//}
//
//public class Main
//{
// public static void main(String[] args) {
// SharedBoard board = new SharedBoard();
//
// Thread th1 = new StudentThread("kitae", board);
// Thread th2 = new StudentThread("hyosoo", board);
//
// th1.start();
// th2.start();
// }
//}
//import javax.swing.*;
//import java.awt.*;
//import java.awt.event.*;
//
//class MyLabel extends JLabel
//{
// private int barSize = 0;
// private int maxBarSize;
//
// public MyLabel(int maxBarSize)
// {
// this.maxBarSize = maxBarSize;
// }
//
// public void paintComponent(Graphics g)
// {
// super.paintComponent(g);
// g.setColor(Color.magenta);
// int width = (int)(((double)(this.getWidth()))/maxBarSize*barSize);
// if(width == 0) return;
// g.fillRect(0, 0, width, this.getHeight());
// }
// synchronized public void fill()
// {
// if(barSize == maxBarSize)
// {
// try
// {
// wait();
// }
// catch(InterruptedException e)
// {
// return;
// }
// barSize++;
// repaint();
// notify();
// }
// }
// synchronized public void consume()
// {
// if(barSize == 0)
// {
// try
// {
// wait();
// }
// catch(InterruptedException e)
// {
// return;
// }
// barSize--;
// repaint();
// notify();
// }
// }
//}
//class ConsumerThread extends Thread
//{
// private MyLabel bar;
// public ConsumerThread(MyLabel bar)
// {
// this.bar = bar;
// }
// public void run()
// {
// while(true)
// {
// try
// {
// sleep(200);
// bar.consume();
// }
// catch (InterruptedException e) {
// // TODO: handle exception
// return;
// }
// }
// }
//}
//
//public class Main extends JFrame
//{
// private MyLabel bar = new MyLabel(100);
//
// public Main(String title)
// {
// super(title);
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Container c= getContentPane();
// c.setLayout(null);
// bar.setBackground(Color.orange);
// bar.setOpaque(true);
// bar.setLocation(20,50);
// bar.setSize(300, 20);
// c.add(bar);
//
// c.addKeyListener(new KeyAdapter() {
// public void keyPressed(KeyEvent e)
// {
// bar.fill();
// }
// });
// setSize(350,200);
// setVisible(true);
//
// c.setFocusable(true);
// c.requestFocus();
// ConsumerThread th = new ConsumerThread(bar);
// th.start();
// }
// public static void main(String[] args) {
// new Main("아무키나 빨리 눌러 바 채우기");
// }
//}