Class DefaultThreadIDProvider

  • All Implemented Interfaces:
    ThreadIDProvider

    public class DefaultThreadIDProvider
    extends java.lang.Object
    implements ThreadIDProvider
    Simple ThreadIDProvider implementation for getting the current thread ID.
    • Constructor Detail

      • DefaultThreadIDProvider

        public DefaultThreadIDProvider()
    • Method Detail

      • convertNativeThreadIDToPositiveInteger

        public static int convertNativeThreadIDToPositiveInteger​(long nativeThreadID)
        Converts a native thread id to a positive integer Thread.currentThread().getId()

        Thread.currentThread().getId() returns a long value. The Beacon protocol requires the thread id to be a positive integer value. By using the xor operation between higher and lower 32 bits of the long value we get an integer value. The returned integer can be negative though. Therefore the most significant bit is forced to '0' by a bitwise-and operation with an integer where all bits except for the most significant bit are set to '1'.

        Parameters:
        nativeThreadID - the native thread id returned by
        Returns:
        a positive integer value calculated from the native thread id