]
Mark Little commented on JBTM-2949:
-----------------------------------
Don't forget about public API changes, if any.
Remove synchronization from ThreadUtil.getThreadId
--------------------------------------------------
Key: JBTM-2949
URL:
https://issues.jboss.org/browse/JBTM-2949
Project: JBoss Transaction Manager
Issue Type: Enhancement
Reporter: Luis Barreiro
Attachments: specj_349Q.png
JBTM-2808 adds synchronization on {{ThreadUtil.getThreadId()}} but that solution does not
scale well enough under high contention.
There seems to be ways to remove this synchronization:
# *ConcurrentWeakHashMap* - replace the current {{WeakHashMap}} for a similar data
structure that can handle concurrent access. This keeps the same behavior.
# *Use Thread.getId()* - remove all mappings and generate the {{threadId}} from the
{{Thread}}. Although the javadoc mentions that IDs can be reused, the implementation is a
counter, like what {{ThreadUtil}} has now. This is the simplest and most elegant fix.
# *Remove {{threadId}}* - remove the generation of {{threadId}} and use the {{Thread}}
throughout the code, generating string IDs when necessary. Probably yields the best
performance, but requires the most changes.