加入线程;为什么? [英] Joining threads; why?

查看:59
本文介绍了加入线程;为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能给我一个实际的例子说明为什么我会加入线程吗?我是

假设您通常会加入一个后台线程,其中包含UI

线程,而不是背景的背景,但是因为我要求

第一名,假设假设非常假设。


谢谢,

Eric

Can someone give me a practical example of why I would join threads? I am
assuming that you would typically join a background thread with the UI
thread and not a background to a background, but since I''m asking in the
first place, assume that assumption to be very assuming.

thanks,
Eric

推荐答案

Eric,


这取决于你想要做什么。我可以想到的一个例子是
,当你有两个不相关的数据集需要处理时。

你必须处理它们,然后执行一个第三个过程。

第一个和第二个是无关的,但第三个不能执行,直到

处理前两个。


作为一个非常简单的例子,让我们假设你有两个专有的

结构化文件,你想要加入一个数据集和一些

的原因。你可以解析一个线程上的一个文件,另一个解析另一个

线程。然后,您将等到它们都被解析后将它们添加到数据集中。在这种情况下,你会加入其他线程做

工作,等待它们完成,这样你就可以继续合并了。


希望这个帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Eric Sabine" < mopar41@mail_after_hot_not_before.com>在消息中写道

新闻:eX ************** @ tk2msftngp13.phx.gbl ...
Eric,

It depends on what you are trying to do. One example I can think of
would be when you have two unrelated sets of data which you need to process.
You have to process both of them, and then perform a third process. The
first and the second are unrelated, but the third can''t be executed until
the first two are processed.

As a really simple example, let''s say you have two proprietary
structured files, which you want to join into a data set and for some
reason. You could parse one file on one thread, and another on another
thread. You would then wait until they were both parsed to add them into
the data set. In that case, you would join on the other threads doing the
work, waiting for them to complete so you could proceed with the merge.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Eric Sabine" <mopar41@mail_after_hot_not_before.com> wrote in message
news:eX**************@tk2msftngp13.phx.gbl...
有人可以给我一个为什么我会加入线程的实际例子?我假设您通常会加入一个后台线程与UI
线程而不是后台背景,但是因为我在首先要求,所以假设这个假设非常假设。

谢谢,
Eric
Can someone give me a practical example of why I would join threads? I am
assuming that you would typically join a background thread with the UI
thread and not a background to a background, but since I''m asking in the
first place, assume that assumption to be very assuming.

thanks,
Eric



加入一个线程,实际上意味着结束/关闭线程,通常

a线程加入他们自己开始的线程,虽然你可以用另一种方式做b $ b,但大多数情况下这样做是没有意义的。


-

cody


免费工具,游戏和幽默
http://www.deutronium.de.vu || http://www.deutronium.tk

" Eric萨宾" < mopar41@mail_after_hot_not_before.com> schrieb im Newsbeitrag

新闻:eX ************** @ tk2msftngp13.phx.gbl ...
Joining a thread, practically means ending/closing the thread, and normally
a thread joins threads which they started by theirselves, although you can
do it the other way around but most times it doesn''t make sense to do so.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"Eric Sabine" <mopar41@mail_after_hot_not_before.com> schrieb im Newsbeitrag
news:eX**************@tk2msftngp13.phx.gbl...
有人可以给我一个为什么我会加入线程的实际例子?我假设您通常会加入一个后台线程与UI
线程而不是后台背景,但是因为我在首先要求,所以假设这个假设非常假设。

谢谢,
Eric
Can someone give me a practical example of why I would join threads? I am
assuming that you would typically join a background thread with the UI
thread and not a background to a background, but since I''m asking in the
first place, assume that assumption to be very assuming.

thanks,
Eric



好的,好像这两个好例子加入后台线程。谢谢。

如果用UI线程加入一个worker。你有没有这样做过?


Nicholas Paldino [.NET / C#MVP]写道:
OK those seem like two good examples of joining background threads. Thanks.
What about joining a worker with the UI thread. Do you ever do that?

Nicholas Paldino [.NET/C# MVP] wrote:
Eric,

这取决于你想做什么。我可以想到的一个例子就是当你有两个不相关的数据集需要处理时。您必须处理它们,然后执行第三个过程。第一个和第二个是无关的,但第三个是不能执行的,直到前两个被处理。

作为一个非常简单的例子,让我们说你有两个专有的结构化文件,您希望将其加入数据集并出于某些原因。你可以在一个线程上解析一个文件,在另一个线程上解析另一个文件。然后,您将等到它们都被解析为
将它们添加到数据集中。在这种情况下,你会加入
其他线程来完成工作,等待它们完成,这样你就可以继续合并。
希望这会有所帮助。

Eric Sabine < mopar41@mail_after_hot_not_before.com>在消息中写道
新闻:eX ************** @ tk2msftngp13.phx.gbl ...
Eric,

It depends on what you are trying to do. One example I can think
of would be when you have two unrelated sets of data which you need
to process. You have to process both of them, and then perform a
third process. The first and the second are unrelated, but the third
can''t be executed until the first two are processed.

As a really simple example, let''s say you have two proprietary
structured files, which you want to join into a data set and for some
reason. You could parse one file on one thread, and another on
another thread. You would then wait until they were both parsed to
add them into the data set. In that case, you would join on the
other threads doing the work, waiting for them to complete so you
could proceed with the merge.
Hope this helps.

"Eric Sabine" <mopar41@mail_after_hot_not_before.com> wrote in message
news:eX**************@tk2msftngp13.phx.gbl...
有人能给我一个实际的例子说明为什么我会加入线程吗?
我假设您通常会加入一个后台线程与UI线程而不是背景的背景,但是因为我在第一次询问地方,假设假设是非常假设的。谢谢,
Eric
Can someone give me a practical example of why I would join threads?
I am assuming that you would typically join a background thread with
the UI thread and not a background to a background, but since I''m
asking in the first place, assume that assumption to be very
assuming. thanks,
Eric



这篇关于加入线程;为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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