title: Passing a static variable with multiple different threads running - TestNG
body: <p>I am using TestNG in order to run automated mobile tests in parallel using Appium. </p>
  
  <p>I have a method in one class that initiates an AppiumDriver object.</p>
  
  <p>I call this method from my TestNG class in order for each thread to create it's own instance of the driver. Trouble is, because it's a static variable, when each of the threads tries to access the driver from <strong>another class</strong> via a static method:</p>
  
  <p>There is always conflicts, as each thread only has access to a single implementation of the AppiumDriver object.</p>
  
  <p>I understand i can bypass this by having all this code within a single class that the TestNG XML file communicates with, but this is messy and i'd prefer to have separate classes for different parts of functionality.</p>
  
  <p>For example, i have a custom TestNG listener that i would like to print driver details each thread is using after each test method is run. With the following method:</p>
  
  <p>However, this always prints the last running thread's driver.</p>
  
  <p>How might i go about ensuring the returned driver the from the <code>method is consistent to the driver that was created in the</code> method?</p>