Say that (possibly in a separate thread) I am running some ClassA.foobar () method. Inside this method there is an attempt (possibly catch) to finally block.
Now, if the last reference to this ClassA object (or to this thread) is lost when execution is still in the middle of the try block (or catch block), can this object (/ thread) get garbage collection before I get to the block ? In other words: is the finally block complete even if there are no strong references to the object (/ stream) remaining in memory?
(I don't know how the GC handles orphaned live streams.)
Mannequin example:
[Some context]
{
ClassA classA = new ClassA();
//Point is this instance and a reference to it exists
class ClassA
{
public void foobar()
{
try
{
classA = null;
//Point is that the last reference to this instance is lost,
//and that this happens at this point in foobar() execution.
//The actual location of this line of code is irrelevant.
}
finally
{
//some important stuff here!
}
}
}
}