Why is Thread not an abstract class and start() not final?

后端 未结 4 1134
北海茫月
北海茫月 2021-01-30 10:05

Why was the Thread class implemented as a regular class and not an abstract class with run() method being abstract.

Will it po

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-30 10:27

    Why is Thread.start() not final?

    Are you sure you would never want to override it?

    Class MyThreadFactory implements ThreadFactory {
        @Override
        public Thread newThread(Runnable r) {
            return new Thread(r) {
                @Override
                public void start() {
                    LOGGER.info("Starting thread " + this);
                    super.start();
                }
            };
        }
    }
    

提交回复
热议问题