Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing of threadlocal variable

Tags:

java

I have a very simple question. Given that Threadlocal variables are declared with static modifier, it is expected that it will be stored in heap. Is this assumption correct?

like image 354
user1588737 Avatar asked Jan 14 '23 00:01

user1588737


1 Answers

All Java objects (reference types) are stored on the heap. It has nothing to do with static.

2.5.3 Heap

The Java Virtual Machine has a heap that is shared among all Java Virtual Machine threads. The heap is the run-time data area from which memory for all class instances and arrays is allocated.

like image 68
Matt Ball Avatar answered Jan 19 '23 10:01

Matt Ball