Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

以下程序运行的结果为 ( ) public class Example extends Thread{ @Override public void run(){ try { Thread.sleep(1000); } catch (InterruptedException e){ e.printStackTrace(); } System. out .print( "run" ); } public static void main(String[] args){ Example example= new Example(); example.run(); System. out .print( "main" ); } } #45

Open
waylau opened this issue Jul 4, 2020 · 1 comment

Comments

@waylau
Copy link
Owner

waylau commented Jul 4, 2020

以下程序运行的结果为 ( ) public class Example extends Thread{ @OverRide public void run(){ try { Thread.sleep(1000); } catch (InterruptedException e){ e.printStackTrace(); } System. out .print( "run" ); } public static void main(String[] args){ Example example= new Example(); example.run(); System. out .print( "main" ); } }(2分)

A. run main
B. main run
C. main
D. run
E. 不能确定

你的回答B 是错误的。估计他是想考线程执行的不确定性吧,估计是E

@wangfei660
Copy link

选择A example.run() 是直接执行了run而不是多线程。多线程必须是example.start() 才对

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants