Reputation: 727
For data load i am using groovy script. where I am using multithreading concept. But when i start data loading after certain interval data load get stopped and JVM start doing Garbage collection. My question is will it be good idea that set object as null and clear collection in method after use at the end of the method?
Other best approaches are well come Thanks in advance.
Upvotes: 0
Views: 626
Reputation: 21
In multithreading try to define variables globally write as possible as local variable with in the method and inside the loop or if condition depending their scope of use.
Upvotes: 1
Reputation: 79828
It depends on what type of variable you're using to refer to the object.
Upvotes: 2
Reputation: 1757
It does not make a difference to garbage collection. Once your method is over and no more references to object/collection exists GC will be able to clean them. It does not make a difference if object/collection become inaccessible because you nulled a reference or method which locally hold last reference has finished.
Upvotes: 1