线程感知和线程安全有什么区别?
线程意识和线程安全之间有什么区别?
What is the difference between thread-awareness and thread-safety?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
线程意识和线程安全之间有什么区别?
What is the difference between thread-awareness and thread-safety?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
礼貌http://sreekalyan.blogspot.com/2007/ 01/thread-safe-and-thread-aware.html
线程感知
在任何给定时间,最多有一个线程可以在该对象上处于活动状态。该对象知道它周围的线程,并通过将所有线程放入队列来保护自己免受线程的影响。由于在任何给定时间该对象上只能有一个活动线程,因此该对象将始终保留其状态。不会有任何同步问题。
线程安全:
在给定时间,多个线程可以在该对象上处于活动状态。对象知道如何处理它们。它已正确同步对其共享资源的访问。它可以在该多线程环境中保留其状态数据(即,它不会陷入中间和/或不确定状态)。在多线程环境中使用该对象是安全的。
使用既不是线程感知的也不是线程安全的对象可能会导致获取不正确的随机数据和神秘的异常(由于在线程正在使用该对象并且处于不稳定的中间状态时尝试访问该对象)在第二个线程访问的瞬间)。
courtesy http://sreekalyan.blogspot.com/2007/01/thread-safe-and-thread-aware.html
Thread Aware
At any given time, at most one thread can be active on the object. The object is aware of the threads around it and protects itself from the threads by putting all the threads in a queue. Since there can be only a single thread active on the object at any given time, the object will always preserve its state. There will not be any synchronization problems.
Thread safe:
At a given time, multiple threads can be active on the object. The object knows how to deal with them. It has properly synchronized access to its shared resources. It can preserve its state data in this multi-threaded environment (i.e. it will not fall into intermediate and/or indeterminate states). It is safe to use this object in a multi-threaded environment.
Using an object that is neither thread-aware nor thread-safe may result in getting incorrect and random data and mysterious exceptions (due to trying to access the object when it is being used by a thread and is in an unstable, in-between state at the instant of access of the second thread).
我相信执行自己的互斥锁序列化的函数是线程安全的,但可能不是线程感知的。
I would believe that a function which does its own mutex locking serialization is thread-safe, but perhaps not thread aware.