Java does not have “global” variables. All data access is via a Class, and then 
possibly and instance of a Class. Contrast this with “globals” in C - the 
variable - if declared external is visible to all code anywhere (there are more 
modern ways to namespace this for some level of protection).

When declaring a ThreadLocal in Java, it still must be accessed using the Class 
or instance accessor, which also means, since you can control 
private/protected/package level access, you can prevent 
unauthorized/uncontrolled mutation - this is completely different than 
historical "globals” and the problems surrounding them.

> On Jan 17, 2019, at 2:19 PM, Ian Denhardt <i...@zenhack.net> wrote:
> 
>> They are not global variables, they are class variables. There's a
>> huge difference.
> 
> Can you elaborate? I don't see a meaningful difference vs. Go's
> package-level var.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to