|
|
Re: i don't understand i ?
|
Posted: Oct 27, 2004 1:05 AM
|
|
the method finalize is called everytime gc() runs, because you never create a reference to the chair object.
The point is, that gc() is called from the Java Virtual Machine "randomly", you can't predict when it's called.
So: The construction of chairs does NOT stop at i = 47. But it stops, when gc() calls the finalize() method at chair nr. 47. Is this clear? You have 2 different asynchrone Threads. The first one does not stop at i == 47, but at f == true. The second one runs later, when ther were created a lot of chairs allready. Then it arrives at a point when the handled chair has i == 47 and sets f=true
I don't know why i==created-4, but my guess is that it has something to do with the time the System needs to handle static variables.
To the point that i was 1173, than it was below 100. Who says the objects get destroyed in the order they were created? Maybe (just maybe) the system first looks at the last created object, then begins to search for other lost objects.
I don't know the internal routines of the Java Virtual Machine very good, but maybe I can halp YOU to understand them.
|
|