线程,任务和公司战... [英] Threads, Tasks and company war...

查看:101
本文介绍了线程,任务和公司战...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我们目前正在与某种与线程和任务相关的公司大战.
这全都与这里用于提取电子邮件的服务有关.
在启动时,启动一个线程,该线程在内部运行Email-Puller,该线程内部使用多个任务来重复地从多个帐户中提取电子邮件(每个帐户都有一个任务).

最近,该服务引发了异常,使所有内容都处于悲惨状态".

现在出现了几个问题,我们无法就适合最佳实践和类似方法的解决方案达成共识.

当前,如果发生异常,该服务只是关闭.
决策者对此表示满意,这真是令人惊讶...

我告诉他们,需要执行处理以关闭每个正在运行的任务,然后在发生错误时关闭运行的主线程.然后可以重新启动主线程,以便该服务保持运行.决策者只是说不,由于时间相关的问题,我们只是重新启动它.

如果服务意外停止,在这种故障下是否有可能无法自动关闭某些任务?
除了关闭不会由于实施而导致数据丢失(最坏的情况是将电子邮件两次拉入我们的系统)这一事实之外,还有一种让应用程序崩溃并依靠其子任务/的可接受方法.线程蜂自动关闭吗?

您的意见是什么,我很高兴听到他们的消息.
最好的问候
Andy

Hi all,
we currently fight some kind of company war related to threading and tasks.
It''s all about a service that is used here for pulling emails.
On start a thread is launched that runs the Email-Puller wich internally uses several tasks to repeadly pull emails from several accounts (each account has one task).

Recently the service threw an exception leaving everything in a "miserable state".

Now several questions came up where we could not agree on a solution that fits best practices and stuff alike.

Currently the service just shuts down if an exception occurs.
Decision makers are fine with that, how surprising...

I told them that handling needs to be implemented to shut down each running task and then the main thread that runs if an error occurs. The Main-Thread could then be restarted so that the service keeps running. Decision makers just say nah, we just restart it because of time-related issues.

Is it possible that on such a failure some tasks are not automatically shut down if the service unexpectedly stops?
Besides the fact that a shutdown will not cause data-loss due to its implementation (worst case would be that an email would be pulled twice into our system) is that an acceptable way to let an application crash and rely on its sub-tasks/threads beeing shut down automatically?

What''s your opinion, I''ll be happy to hear them.
best regards
Andy

推荐答案

您好,这里 a>
现在,以我个人的观点,现在每个任务都必须处理从代码中引发的异常,这意味着该服务必须在其他线程引发异常的同时继续工作.可以发出shutdown命令,但这必须是因为它是预期的
Hi, there is a great a articale on threading here
now in my personal opinion each task must handle the exception that raising from the code been execued, meaning that the service must continue working while other threads raise exceptions. shutdown command can be issued but it must be because it has been intended


这篇关于线程,任务和公司战...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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