Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 23-Jan-18 21:09pm

1 solution

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.
 
Share this answer
 
Comments
Member 11344126 24-Jan-18 3:54am    
thank you for yor opinion. my teacher...

The reason that I have the question is program performence issus.

and so I thought that running process deal with thread.

that if object(class) has another many obejct ( new class() ), performence of

program will be not bed. so I thought that class is properly devided for performence issus.

anwawy. your opinion helped to me. thank you.
OriginalGriff 24-Jan-18 4:07am    
A process is an application (simplifying a lot here) which consists of allocated memory and code, and executes that code using one or more threads. A thread is the basic unit to which the operating system allocates processor time. A thread can execute any part of the process code, including parts currently being executed by another thread, and shares the memory allocated to the process, but each thread has a separate stack so they do not get confused with each other.
Threading and performance is a knotty subject: adding threads may slow down an application as each thread adds an overhead and if there aren't sufficient processor cores to run them at the same time, then extra processing time is taken up switching between them.

Performance comes in two types: processor time and memory usage, and generally speaking an improvement in one is at the expense of the other! Classes are memory related, and are not in any way thread related: so their only impact on processing time is in terms of how much memory they allocate (which can be a very time consuming process!)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900