java shared variables
<p>I was wondering how multiple threads could access the same variable.  If the variable is non static and each thread is its own thread object, how can you access the same variable?  For instance supposed I have a function that finds the maximum of a 2D array.  If each thread finds the maximum of a row, and each thread also maintains a local maximum of that row and compares that local maximum to a shared maximum and updates the shared maximum accordingly, how would you access the shared maximum if you have different thread objects?</p>

<p>For example in this code i have </p>

<pre><code>for(int i=0; i&lt;input.length; i++){
rowArray = input[i];
teste r1 = new teste(rowArray);
runnables.add(r1);
}
</code></pre>

<p>this calls the teste class which implements runnable, and instantiates it with a row of the array.  Then it adds it to an arraylist of runnables.  Now, each teste object has its own variable and reference, so how would you be able to "share" them if you are creating different teste objects for each row?  Basically i want to pass by reference instead of value >,></p>
