+ Reply to Thread
Results 1 to 2 of 2

Thread: Is shared_ptr thread safe? Is is safe to use it across multiple threads?

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    27

    Is shared_ptr thread safe? Is is safe to use it across multiple threads?

    I am learning new C++ standard and came across shared_ptr. I liked it very much. I have query related to multi-thread and shared_ptr. Can I use shared_ptr object across multiple thread or is shared_ptr thread safe? Please answer. Thanks.

  2. #2
    Junior Member
    Join Date
    Apr 2012
    Posts
    43
    Yes, and
    a. shared_ptr is thread safe.
    b. You can use it as shared_ptr uses thread safe mechanism that maintains the reference counting.
    c. This way you are free to use it and when last object reference goes ouf of scope object will automatically destroy.

    Hope this helps.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts