---
title: "Comment by Mark on \"Threads in rust\" | Hashnode"
description: "This is very detailed, way more interesting facts than I was expecting. I think many of the sections cover big enough topics that they could&#39;ve been whole p"
url: "https://hashnode.com/posts/threads-in-rust/5cfa96c13457f5cf463c2674/comment/5cfacde358d2afbf3c17ec51"
---

[Discussion](https://hashnode.com/posts/threads-in-rust/5cfa96c13457f5cf463c2674)

Comment [Threads in rust](https://hashnode.com/posts/threads-in-rust/5cfa96c13457f5cf463c2674)

[Mark](https://hashnode.com/@mverleg)

[Jun 7, 2019](https://hashnode.com/posts/threads-in-rust/5cfa96c13457f5cf463c2674/comment/5cfacde358d2afbf3c17ec51)

This is very detailed, way more interesting facts than I was expecting.

I think many of the sections cover big enough topics that they could've been whole posts, so probably not an introduction level post. But personally I liked that, good to see some in-depth posts!

> A RefCell is not threadsafe

Just to clarify for those less familiar with Rust: you can't actually do anything unsafe - you just can't share it between threads at all, it won't compile.

I tend to end up with `RwLock`s when doing threading code, not sure if that's a problem... Probably not super performance, but it's easy, and I like the way Rust ensures that you lock long enough but not too long.

I only found out after a while that `RwLock` exists and while less fair, is often faster than `Mutex` (which seems to be the most mentioned online). \[By 'less fair' I mean that, in my understanding, it does not give equal chance to each thread... I think it can starves out writes?\]

[j](https://hashnode.com/@chilimatic)

[Jun 8, 2019](https://hashnode.com/posts/threads-in-rust/5cfa96c13457f5cf463c2674/comment/5cfacde358d2afbf3c17ec51#reply-5cfb9c227ef4b1a112ac6993)

[Mark](https://hashnode.com/@mverleg) Actually I fell like there should be way more things in there. But my blogs are usually more of katharsis and I always feel like there are so many pieces missing that I should add.

RWLocks, if I read this correct there are different approaches to the preferences if the kernel starves the reader or the writers. Which is a very interessting point I did not know. I was going for my mental model and your point helps a lot :) thx. I will add it up there as well.

[sites.google.com/site/embeddedmonologue/home/mutu…](https://sites.google.com/site/embeddedmonologue/home/mutual-exclusion-and-synchronization/rwlock-and-reader-writer-starvation)

for more details :)
