日期:2014-05-20  浏览次数:20680 次

内部类编译时问题?????
public   class   SimpleThreads   {

        //Display   a   message,   preceded   by   the   name   of   the   current   thread
        static   void   threadMessage(String   message)   {
                String   threadName   =   Thread.currentThread().getName();
                System.out.format( "%s:   %s%n ",   threadName,   message);
        }

        private   static   class   MessageLoop   implements   Runnable   {
                public   void   run()   {
                        String   importantInfo[]   =   {
                                "Mares   eat   oats ",
                                "Does   eat   oats ",
                                "Little   lambs   eat   ivy ",
                                "A   kid   will   eat   ivy   too "
                        };
                        try   {
                                for   (int   i   =   0;   i   <   importantInfo.length;   i++)   {
                                        //Pause   for   4   seconds
                                        Thread.sleep(4000);
                                        //Print   a   message
                                        threadMessage(importantInfo[i]);
                                }
                        }   catch   (InterruptedException   e)   {
                                threadMessage( "I   wasn 't   done! ");
                        }
                }
        }

        public   static   void   main(String   args[])   throws   InterruptedException   {


                //Delay,   in   milliseconds   before   we   interrupt   MessageLoop