---
title: "Comment by Benjamin Eder on \"Rust + Actix + CosmosDB (MongoDB) tutorial API\" | Hashnode"
description: "Hi there! Thanks for the tutorial. Pretty sure you do not need to use Mutex for sharing the MongoDB client instance between threads. Comment from docs of Client"
url: "https://hashnode.com/posts/rust-actix-cosmosdb-mongodb-tutorial-api/60d84427de92ef110afdeffe/comment/62051a56b6c216065a35d96b"
---

[Discussion](https://hashnode.com/posts/rust-actix-cosmosdb-mongodb-tutorial-api/60d84427de92ef110afdeffe)

Comment [Rust + Actix + CosmosDB (MongoDB) tutorial API](https://hashnode.com/posts/rust-actix-cosmosdb-mongodb-tutorial-api/60d84427de92ef110afdeffe)

[Benjamin Eder](https://hashnode.com/@bennyboer)

[Feb 10, 2022](https://hashnode.com/posts/rust-actix-cosmosdb-mongodb-tutorial-api/60d84427de92ef110afdeffe/comment/62051a56b6c216065a35d96b)

Hi there! Thanks for the tutorial. Pretty sure you do not need to use Mutex for sharing the MongoDB client instance between threads.

Comment from docs of `Client`:

> `Client` uses [`std::sync::Arc`](https://doc.rust-lang.org/std/sync/struct.Arc.html) internally, so it can safely be shared across threads or async tasks.

[Jakub Barszczewski](https://hashnode.com/@jbarszczewski)

[Feb 11, 2022](https://hashnode.com/posts/rust-actix-cosmosdb-mongodb-tutorial-api/60d84427de92ef110afdeffe/comment/62051a56b6c216065a35d96b#reply-62062a879e350308247feef3)

Hi Benjamin, Thank you for reading it! As for Mutex and Arc they serve different purposes and complement each other. Arc is used for reference counting and making sure you can safely pass and access object from multiple threads/tasks, and Mutex makes sure only one can change it at a time by putting a lock on it.

But you're right, we could remove the Mutex in this situation as the Arc is all we need. Great spot! :)
