What's the difference between the static Thread.currentThread().getName() and getName() of a particular Thread instance?
The difference is getName() is an instance method, meaning it operates on an instance of the Thread class.
Thread.getCurrentThread() is a class or static method, meaning it does not operate on an instance of Thread but rather on its class.
The ultimate difference is this: if you call Thread.currentThread().getName(), currentThread() will return an instance of Thread, which you can then call getName() on that instance. You cannot call Thread.getName() because getName() has to be called on an instance of Thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With