我可以从Servlet产生线程吗? [英] Can i spawn a thread from a servlet?

查看:45
本文介绍了我可以从Servlet产生线程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开始我的主要问题之前,我想问一个基本问题.

I would like to ask a basic question before i get on to my main question .

可以说我正在运行一个简单的Java程序,该程序在main函数中产生一个线程.当主要功能完成时,线程会继续运行吗? 线程之间是否有父/子关系的概念.

Lets say i am running a simple Java program, which spawns a thread in the main function. Will the thread continue to run when the main function completes? Is there a concept of parent/child relationships between threads.

我有一个Servlet,需要很长时间才能处理请求(5分钟).我可以从主servlet中产生一个后台线程来处理工作吗?很快回来.即使主servlet完成处理后,后台线程也会继续运行吗?

I have a servlet which takes a long while to process a request (5 mins). Can i spawn a background thread from the main servlet to handle the work & return soon. Would the background thread keep running even when the main servlet has finished processing?

推荐答案

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆