Local var passed to thread. May it get reclaimed by GC???

  • Thread starter Thread starter Bob Rock
  • Start date Start date
B

Bob Rock

Hello,

my questiong is, I believe, very simple.
I have a method and inside it I'm passing a local variable (of a
reference type) to a newly created thread (created inside the method
itself). Since the method may end while the thread may not have yet
completed its work, I was wondering if anything must be done to avoid
the garbage collector reclaiming the variable before the thread has
completed.


Thx.
Bob Rock
 
Bob,

Can you post parts of your code? How exactly are you passing the
variable to the newly created thread?



Mattias
 
Bob Rock said:
my questiong is, I believe, very simple.
I have a method and inside it I'm passing a local variable (of a
reference type) to a newly created thread (created inside the method
itself). Since the method may end while the thread may not have yet
completed its work, I was wondering if anything must be done to avoid
the garbage collector reclaiming the variable before the thread has
completed.

If the other thread has a reference to the object, you needn't worry
about the garbage collector reclaiming it early.
 
Back
Top