java: how to set a global thread-ID?
问题 Is there any possibility to set unique ID for a thread? In distributed system where threads are created on many different machines (e.g. by RMI)? I need it to create log messages. From my research I know that it can be done using log4j mdc/ndc, but only in single thread. My problem is that ID has to be set when thread is created (to use the same ID for threads on different JVM but for the same request) I am new to distributed systems. 回答1: If you want to have a globally unique request id, you