Package com.dynatrace.openkit.providers
Class DefaultThreadIDProvider
- java.lang.Object
-
- com.dynatrace.openkit.providers.DefaultThreadIDProvider
-
- All Implemented Interfaces:
ThreadIDProvider
public class DefaultThreadIDProvider extends java.lang.Object implements ThreadIDProvider
Simple ThreadIDProvider implementation for getting the current thread ID.
-
-
Constructor Summary
Constructors Constructor Description DefaultThreadIDProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intconvertNativeThreadIDToPositiveInteger(long nativeThreadID)Converts a native thread id to a positive integer Thread.currentThread().getId()intgetThreadID()Return s the current thread id
-
-
-
Method Detail
-
getThreadID
public int getThreadID()
Description copied from interface:ThreadIDProviderReturn s the current thread id- Specified by:
getThreadIDin interfaceThreadIDProvider- Returns:
-
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
-
-