问题描述
我正在编写 HTTP THREAD-POOLED WEB SERVER 代码。我尽力制作了我的代码。它也可以正常工作。
I am writing a HTTP THREAD-POOLED WEB SERVER code. I made my code at my best. It works fine also.
但有一个问题,每当我想关闭我的服务器时,我必须使用 CTRL + C
。但这是一个关闭的坏方法。
But there is one problem, whenever I want to shut down my server, I have to use CTRL + C
. But that is a bad way to shut down.
我想很多,在我的代码中添加关机功能。但我无法做到这一点。
I think a lot, to add shutdown feature in my code. But I am unable to do that.
请帮我添加此功能,给出任何建议,我肯定会编码。
Please help me to add this feature, give any suggestion to do that, I will definitely code that.
编辑没有。 1
我认为一种方法是使一个线程只监听键盘给出的STDIN输入。每当它关闭时。它调用 ThreadPol.shutdown()
。通过这种方式,我可以实现这一目标。
One method that I think is to make one thread that is only listening STDIN input given by keyboard. Whenever it gets "SHUTDOWN". It calls ThreadPol.shutdown()
. This way I can achieve this goal.
这是一种正确的方法吗?如果是,请帮我实现。
Is this a right method ? If yes, please help me to implement this.
推荐答案
你可以做到
这篇关于如何添加“SHUTDOWN”功能在MultiThreaded Http Web服务器代码中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!