# Why does the compiler say my type cannot be sent between threads when I start a worker?
Source: https://ruststudio.org/community/t/23/why-does-the-compiler-say-my-type-cannot-be-sent-between-threads-when-i-start-a
Author: Ruststudio Team (staff) | Published: 2026-12-05 | Updated: 2026-12-05 | Checked with: rustc 1.93.0, Windows 11; the failing program was compiled and the message below is its real output (shortened).
Category: Help and questions | Kind: FAQ | Tags: threads, send, rc, gui | Views: 0

## Short answer
The error means the closure captures a value whose type does not implement Send, such as Rc, a raw pointer or a toolkit handle tied to the UI thread. Send plain data to the worker instead, or use Arc for shared data, and send results back through a channel. The real error message is shown below.

## Answer
## Answer
`thread::spawn` requires the closure, and everything it captures, to be `Send`: safe to move to another thread. Some types are deliberately not `Send`. The compiler stops you at build time, which is the point: it prevents a data race.

The usual cause in a desktop program is `Rc`. It counts references without atomic operations, so two threads touching the count could corrupt it.

```rust title=src/main.rs
use std::rc::Rc;
use std::thread;

fn main() {
    let label = Rc::new(String::from("status"));
    let handle = thread::spawn(move || {
        println!("{label}");
    });
    handle.join().unwrap();
}
```

```text
error[E0277]: `Rc<String>` cannot be sent between threads safely
 --> src/main.rs:6:32
  |
6 |       let handle = thread::spawn(move || {
  |                    ------------- ^------
  |                    |             |
  |  __________________|_____________within this `{closure@src/main.rs:6:32: 6:39}`
  | |                  |
  | |                  required by a bound introduced by this call
7 | |         println!("{label}");
8 | |     });
  | |_____^ `Rc<String>` cannot be sent between threads safely
  |
  = help: within `{closure@src/main.rs:6:32: 6:39}`, the trait `Send` is not implemented for `Rc<String>`
```

(File paths in the message were shortened by hand; the rest is as printed.)

Ways to fix it, depending on what you need:

1. **The worker only needs a copy of the data.** Clone the plain value (`String`, numbers, a `Vec`) and move the clone in.
2. **Both sides need the same data.** Replace `Rc` with `Arc`, and add a `Mutex` (or `RwLock`) if either side changes it.
3. **The worker needs to change the UI.** It cannot touch UI objects. Send a message through a channel and let the UI thread apply the change. Toolkit handles are often not `Send` for the same reason; the toolkit's documentation says how to reach the UI from another thread (for example Slint's weak handle with `invoke_from_event_loop`, or egui's `Context::request_repaint`).

## Common mistakes
- Wrapping the type in `unsafe impl Send` to make the error go away. That hides the data race instead of removing it.
- Moving a whole `App` struct into the thread. Move the few fields the worker needs.

## Related questions
### What does Sync mean?
A type is `Sync` if a shared reference to it can be used from several threads. `Arc<Mutex<T>>` is `Send` and `Sync` when `T` is `Send`.

## Sources
- The Rust Book, "Extensible Concurrency with the Sync and Send Traits": https://doc.rust-lang.org/book/ch16-04-extensible-concurrency-sync-and-send.html (read 2026-12-05)
- Slint, `invoke_from_event_loop`: https://docs.rs/slint/1.18.1/slint/fn.invoke_from_event_loop.html (read 2026-12-05)
