I have a question regarding synchronization of code that is executed by several threads:
As far as I know each thread has its own stack, hence, non-static variables
Some key points which can help clarifying your doubts -
Objects are always allocated on heap.
Class level variables are shared across threads (thread of same object )
Local variables are always thread safe (if not exposed to outside world in non thread safe manner)