Skip to content

Thread.GetHashCode uniqueness #3054

Open
@user2150

Description

@user2150

"In managed threading, Thread.GetHashCode is the stable managed thread identification. For the lifetime of your thread, it will not collide with the value from any other thread, regardless of the application domain from which you obtain this value."

But from here (Thread.GetHashCode Method): https://docs.microsoft.com/en-us/dotnet/api/system.threading.thread.gethashcode?view=netframework-4.8

"The hash code is not guaranteed to be unique. Use the ManagedThreadId property if you need a unique identifier for a managed thread."

Apparently, the latter statement is incorrect as GetHashCode and ManagedThreadId both return the same value and seem to be the same because GetHashCode actually returns m_ManagedThreadId (although it's unclear how it is initialized).

Since there's no feedback capability in the GetHashCode article, I post here.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri2Indicates issues/PRs that are medium priorityarea-System.Threadingdoc-bugProblem with the content; needs to be fixeddotnet/prodwaiting-on-feedbackIndicates PRs that are waiting for feedback from SMEs before they can be merged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions