Skip to content

ComplexCurrentThreadTest #2

Open

Description

@Goddyc

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

Activity

  1. Luolanjiao commented on May 6, 2019

    @Luolanjiao

    你没看清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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions