java - In a swing worker is it possible to kill the thread? -


i load data in background mode swing worker thread. simplified version of routine below. important part work2 holds object until thread done , work2 gets null value.

what might expect garbage collection remove thread, see in debugger swingworker-pool-1-thread-1-running. point of view, have no more use thread, since loading done.

it best off ignore fact thread still running, ask anyway. desirable explicitly kill thread? haven't yet looked explicit command because used setting object null , there no more references, java kills things me.

so best advice? kill or ignore it?

thanks, ilan

protected void loaddata(petctframe par1, arraylist<imageplus> imglist, arraylist<integer>seriestype) {     work2 = new bkgdloaddata();     work2.addpropertychangelistener(new propertychangelistener() {         @override         public void propertychange(propertychangeevent evt) {             string propertyname = evt.getpropertyname();             if( propertyname.equals("state")) {                 swingworker.statevalue state = (swingworker.statevalue) evt.getnewvalue();                 if( state == swingworker.statevalue.done) {                     work2 = null;                 }             }         }     });     work2.execute(); } 

once swingworker first used, pool initialized , there no need manage it.

as mention of garbage collection, has nothing thread management. thread object not thread, handle object allows start , manage lifecycle of thread of execution. underlying thread started, thread instance statically reachable thread.currentthread(), therefore instance not subject garbage collection long thread alive.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -