The Java Program: Main.java

  1 // Main.java -- GUI programs have an event loop
  2 
  3 /*
  4   Merely creating a Swing component causes many things to happen
  5   automatically.  For example, the event loop is started, the
  6   "font.properties" file is read, and so on.
  7 */
  8 import javax.swing.JPanel;
  9 
 10 class Main {
 11    public static void main(String[] args) {
 12       // Create and disregard a Swing component
 13       System.out.println (new JPanel().isDisplayable());
 14       final Thread t = Thread.currentThread();
 15       final int active = t.activeCount();
 16       System.out.println("currently active threads: " + active);
 17       final Thread all[] = new Thread[active];
 18       t.enumerate(all);
 19       for (int i = 0; i < active; i++) {
 20          System.out.println(i + ": " + all[i]);
 21       }
 22 
 23       /*
 24         An ordinary return  now end this program.  The event
 25         loop is in a (non-deamon) thread and the application cannot
 26         end until it is killed.
 27       */
 28       /*
 29         System.exit (0);
 30       */
 31    }
 32 }