Threads within threads in Java?

前端 未结 4 1027
被撕碎了的回忆
被撕碎了的回忆 2020-12-06 06:13

I am currently thinking about how to design a multithreading system in Java that needs to do some heavy network processing and database storage. The program will launch thre

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 06:56

    To answer the question, yes threads can launch other threads.

    Is the hierarchy important?

    You're probably better off using an ExecutorService with a cached thread pool. That way you can pool threads instead of creating lots (which is expensive). ExecutorServices also provide other cool things, and using Callables / Runnables with them is probably much easier to test than mucking about with threads on your own.

提交回复
热议问题