예제 #1
0
 public static void main(String[] args) {
   ClockDisplay cd1 = new ClockDisplay(9, 35);
   int i = 0;
   while (i < 10) {
     System.out.println(cd1.getTime());
     cd1.timeTick();
     i++;
   }
 }
예제 #2
0
 private void start() {
   synchronized (clockDisplay) {
     if (start) {
       label.setText(clockDisplay.refresh());
     } else {
       try {
         System.out.println("µÈ´ýÖÐ");
         clockDisplay.wait();
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     }
   }
 }
예제 #3
0
 private void command(String type) {
   synchronized (clockDisplay) {
     if (type.equalsIgnoreCase("start")) // Æô¶¯
     {
       start = true;
       if (!hasStart) {
         t = new Thread(this);
         hasStart = true;
         t.start();
       }
       clockDisplay.notify();
     } else if (type.equalsIgnoreCase("clear")) // ÔÝÍ£
     {
       start = false;
       clockDisplay.clear();
       label.setText(clockDisplay.toString());
     } else {
       start = false;
     }
   }
 }