I read somewhere that starting a thread has some special effect on the happend before relationship. Now I'm not sure if my code gurantees the happend before relationship, so please enlighten me.
I have a Dispatcher thread and a Worker class implementing the Runnable interface. The Dispatcher thread creates a new instance of the Worker and fills a LinkedList in the Worker instance through the add method with elements.
Then the Dispatcher hands the Worker instance to a ExecutorService via the execute method.
Then the run method in the Worker class starts accessing and removing stuff from the LinkedList.
Does the freshly started instance of the Worker see the same state of the LinkedList as the Dispatcher left it in? Or could it be that LinkedList is in some inconsitent state? Will I have to fill the LinkedList in a sychronized method?