About Timer and Timer Task in Java -


let's have running timer scheduled timertask. if call timer.cancel() kill of variables in timertask or have wait gc? also, can reassign new task after calling .cancel()

timer.cancel(); timer = new timer(); messagetimer = new messagetask(); timer.schedule(messagetimer, 1000, 1000); 

or there more suitable way replace timer task in original timer object, or i'm not thinking of?

thanks -t

in java, memory only reclaimed via gc, developer, variables useless (and ready garbage collection) once have no more references them.

in example, creating new timer reassigning =. if there no more references, old 1 garbage collected.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -