We know that Class2, a thread started by Class1, has access to variables declared in Class1. Now, if there are several instances of Class1 running on the same machine, can I be assured that a given Class2 will be referencing only the Class1 that started it? Thanks, Vernon
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
posted
0
Originally posted by Vernon Gibson: Now, if there are several instances of Class1 running on the same machine, can I be assured that a given Class2 will be referencing only the Class1 that started it?
No. There is no isolation whatsoever between Threads. The only way you can assure that your instance of Class2 will refer to the right instance of Class1 is by simply giving it the right Class1 object to work with (note that you will get this automatically if Class2 is a non-static inner class of Class1). - Peter
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.