Andrew John Hughes said the following on 03/13/09 10:13:
The rest of the code deals with allocating an ID to the
thread creating the LogRequest object and doesn't depend on the global
sequence number, so it doesn't matter if this is incremented by
another thread before the constructor completes.  Note that
Thread.currentThread.getId() now provides an identifier for threads as
well, but this will reuse the identifiers of dead threads and could
thus lead to possible confusion between log messages.

Both "thread ids" simply increment an integer. The Thread ID will wrap sooner than the Logger thread ID simply because not all threads will use the logger. But I don't think wrapping is a practical concern in either case.

Still, gratuitous changes seem to always have unintended consequences to some piece of code somewhere, so I wouldn't worry about trying to reuse the Thread getId() here.

David Holmes

Reply via email to