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

ComplexCurrentThreadTest #2

Open
Goddyc opened this issue Dec 14, 2018 · 1 comment
Open

ComplexCurrentThreadTest #2

Goddyc opened this issue Dec 14, 2018 · 1 comment

Comments

@Goddyc
Copy link

Goddyc commented Dec 14, 2018

ComplexCurrentThreadTest测试结果与ReadMe里的说明结果不符合

begin=========
Thread.currentThread().getName=main
this.getName()=Thread-0
end===========
run begin=======
Thread.currentThread().getName=Thread-1
this.getName()=byhieg
run end==========
这是我在eclipse里的执行结果,在执行run的时候Thread.currentThread().getName的结果是Thread-1而不是上面设置的byhieg

@Luolanjiao
Copy link

Luolanjiao commented May 6, 2019

你没看清ReadMe里的测试用例,和代码里的是不一样的。代码里为了说明this.getName()和Thread.currentThread().getName()的不同,特地又new了一个Thread。

setName()之后Thread.currentThread().getName得到的是新new的线程名Thread-1,因为是Thread-1执行start,运行了run方法,所以结果不是设置的byhieg

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