他们说什么时到底意味着什么? [英] What exactly does it mean when they say

查看:93
本文介绍了他们说什么时到底意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此类型的成员对于多线程操作是安全的。实例

会员不保证是线程安全的。

我在你用之前的印象之前你必须做一个

的实例。那么一个类本身如何才能成为线程安全但它不是一个

实例?


我想我不知道究竟什么是线程安全的意思。多个

theads可以使用同一个类的实例吗?

members of this type are safe for multithreaded operations. Instance
members are not guaranteed to be thread-safe.
I''m under the impression before you can use a class you have to make an
instance of it. So how can a class be threadsafe by itself but an
instance of it not be?

I guess I don''t get what exactly being threadsafe means. Multiple
theads can use the same instance of a class?

推荐答案

这些类可能有共享方法。在这种情况下,这些方法是线程安全的
。因此,如果多个线程正在调用相同的共享方法,那么

是安全的,并且开发人员不需要采取额外的预防措施。


如果有2个线程是指向同一个类的实例,然后那些

实例方法不保证是线程安全的,并且由

开发人员来同步访问。 />

" cj" < cj@nospam.nospamwrote in message

news:uN ************** @ TK2MSFTNGP02.phx.gbl ...
Those classes may have shared methods. In which case, those methods are
thread safe. So if multiple threads are calling the same shared method,
that is safe and no extra precautions need to be taken by the developer.

If 2 threads are pointing to the same instance of the class, then those
instance methods are not guaranteed to be thread safe, and it is up to the
developer to synchronize access.

"cj" <cj@nospam.nospamwrote in message
news:uN**************@TK2MSFTNGP02.phx.gbl...

此类型的成员对于多线程操作是安全的。实例

成员不保证是线程安全的。


我在你可以使用你必须制作的课程之前的印象

它的实例。那么一个类本身如何才能成为线程安全但它不是一个

实例?


我想我不知道究竟什么是线程安全的意思。多个theads

可以使用同一个类的实例吗?
members of this type are safe for multithreaded operations. Instance
members are not guaranteed to be thread-safe.
I''m under the impression before you can use a class you have to make an
instance of it. So how can a class be threadsafe by itself but an
instance of it not be?

I guess I don''t get what exactly being threadsafe means. Multiple theads
can use the same instance of a class?



很抱歉,但对我来说,这两种情况听起来是一样的。我不明白

有什么区别。要使用一个类,我必须创建一个

的实例,对吗?然后我有多个线程想要在该类的实例中调用方法

。不是线程安全吗?还是线程安全的?


Marina Levit [MVP]写道:
Sorry but to me these two situations sound the same. I don''t understand
what the difference is. To use a class I have to create an instance of
it, right? Then I have multiple threads that will want to call methods
in that instance of the class. Not thread safe? Or thread safe?

Marina Levit [MVP] wrote:

这些类可能有共享方法。在这种情况下,这些方法是线程安全的
。因此,如果多个线程正在调用相同的共享方法,那么

是安全的,并且开发人员不需要采取额外的预防措施。


如果有2个线程是指向同一个类的实例,然后那些

实例方法不保证是线程安全的,并且由

开发人员来同步访问。 />

" cj" < cj@nospam.nospamwrote in message

news:uN ************** @ TK2MSFTNGP02.phx.gbl ...
Those classes may have shared methods. In which case, those methods are
thread safe. So if multiple threads are calling the same shared method,
that is safe and no extra precautions need to be taken by the developer.

If 2 threads are pointing to the same instance of the class, then those
instance methods are not guaranteed to be thread safe, and it is up to the
developer to synchronize access.

"cj" <cj@nospam.nospamwrote in message
news:uN**************@TK2MSFTNGP02.phx.gbl...

>此类型的成员对于多线程操作是安全的。实例
成员不保证是线程安全的。

我在你可以使用你必须编写一个
实例之前的印象。那么一个类本身如何才能成为线程安全但是它的实例却不是?

我想我不知道究竟是线程安全的意思。多个theads
可以使用同一个类的实例吗?
>members of this type are safe for multithreaded operations. Instance
members are not guaranteed to be thread-safe.
I''m under the impression before you can use a class you have to make an
instance of it. So how can a class be threadsafe by itself but an
instance of it not be?

I guess I don''t get what exactly being threadsafe means. Multiple theads
can use the same instance of a class?



你好cj,
Hello cj,

对不起给我这两种情况听起来是一样的。我不知道
了解不同之处。要使用一个类,我必须创建它的一个

实例,对吧?然后我有多个线程想要在该类的实例中调用
调用方法。不是线程安全吗?或者

线程安全吗?
Sorry but to me these two situations sound the same. I don''t
understand what the difference is. To use a class I have to create an
instance of it, right? Then I have multiple threads that will want to
call methods in that instance of the class. Not thread safe? Or
thread safe?



这种情况​​不是线程安全的。线程安全的情况是当你打电话给共享的时候。方法。这些与实例无关,并且

文档表明它们对于多线程访问是安全的。


-

Jared Parsons [MSFT]
ja******@online.microsoft.com

所有意见都是我自己的意见。所有内容均按原样提供。没有保证,

并且不授予任何权利。

That case is not thread safe. The case that is thread safe are when you
call the "shared" methods. These are not associated with an instance and
the documentation indicates they are safe for multi-threaded access.

--
Jared Parsons [MSFT]
ja******@online.microsoft.com
All opinions are my own. All content is provided "AS IS" with no warranties,
and confers no rights.


这篇关于他们说什么时到底意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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