我想知道是对象(类)之间的关系线程 [英] I wonder that is relation thread in process between object(class)

查看:85
本文介绍了我想知道是对象(类)之间的关系线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个项目中,我曾担任过WPF程序员。



做wpf程序,我觉得这是一个很重的程序,它是asycn程序。 />


所以这里始终是性能问题。所以我有一个问题我想知道。



一个进程有很多线程。然后一个进程中的一个线程处理一个对象(类)?



如果线程handels一个对象(类),我认为很多对象(类)通过启动



程序适用于多线程编程。



我听你的意见。 PLZ。







对不起。我不会说英语。



我尝试过:



in this project, I have worked as a WPF programer.

Doing the wpf program, I have felt that is heavy program which is asycn program.

so here is always performence issuse. and so I have a question I wondered.

one process has a many thread. then does a thread in a process handle one object(class)?

if thread handels one object(class), I think that many object(class) made by starting

program is divided properly for multi thread programing.

I listen your opinion. plz.



Sorry. I dont speak english very well.

What I have tried:

I listen your opinion. plz.

推荐答案

不,线程是处理单元 - 它是在CPU内的核心上执行的代码某个特定的时间,它没有直接链接到任何一个对象。

如果你有一个简单的控制台应用程序,那么它有一个单独的线程,它运行(提供操作系统不需要核心fr一个不同的过程),直到它达到一个不能再做的时候,也许当它等待用户输入一些东西时。当它等待时,应用程序可以做任何其他事情。

如果它启动第二个线程(可能计算出pi的值),那么第二个线程独立于第一个线程运行 - 停顿等待用户,但pi的计算继续进行而没有注意到。



这与对象或类无关,它们只是一个抽象层我们程序员申请提高代码的质量。
No, a thread is a "unit of processing" - it's the code that executes on a core within your CPU at some specific time, it is not directly linked to any one object.
If you have a simple Console app then it has a single thread, and it runs (providing the OS doesn't need the core fr a different process) until it reaches a point when it can't do any more, perhaps when it is waiting for the user to type something. While it waits, the app can do nothing else.
If it starts a second thread (perhaps to work out the value of pi) then that second thread runs independently of the first thread - that "stalls" waiting for the user, but the calculation of pi carries on without noticing.

This has nothing to do with objects or classes, they are just an "abstract layer" that we programmers apply to improve the quality of our code.


这篇关于我想知道是对象(类)之间的关系线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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