java - Should the creation and instantiation of threads always be in the driver class? -


i have 0 experience multi-threading , know if should creating instances , starting each thread in driver class each object of other classes in project? guess need know , bad technique creating threads?

for example, there 3 classes, a, b , driver. can make , start thread instance of class in driver, , since class creates objects of class b in code (no objects of class b directly instantiated or used in driver), can create threads class b within class a? may poor design on part said, attempting learn new things here. in advance!

yes, can create threads anywhere want -- including in thread spawned inside thread spawned driver class.

there are, however, few things need really learn if going thread-ception (you see did?) , daemon , user thread is.

you said driver not have access running thread b. if running thread no longer needed , driver wants stop it? should b stop or not ? comes play whether b daemon thread or not.

multithreading deep subject books dedicated 1 topic. :-) take deep breath cause have long way ahead of you.

i linking 2 tutorials like:
1. vogella: http://www.vogella.com/articles/javaconcurrency/article.html
2. oracle: http://docs.oracle.com/javase/tutorial/essential/concurrency/


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -