java - Threads ends when run finish? -


this question has answer here:

i want know if thread in java closes when run method ends.

i mean, have new thread declaration:

new thread(new submitdataonbackground(handler.getidvalue(), data, this.context)).start(); 

and then, in submitdataonbackground have run method:

public void run() {     submitdatahandler submit = new submitdatahandler(id, data, this.context);     submit.buildandsubmitdata();  } 

after buildandsubmitdata finishes, thread close or have add code somewhere?

i not sure if leaving new thread opened each time call method or ok.

my application server never ends because active whole time. want know amount of threads not outnumbered because creates new ones without closing others when finish.

threads close after run method has been called. read further information https://docs.oracle.com/javase/7/docs/api/java/lang/thread.html

edit: if want avoid behaviour, recommend using threadpools.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -