quest

Sign in to start training

quest keeps your progress, streaks, and scores tied to your account — so you can pick up on any device.

Synced everywhere. Progress follows you across laptop and phone.
Streaks & stats. See your daily run and every score over time.
Your profile. A name and avatar for the work you do here.

We only use Google to sign you in and sync progress. No posting, no contacts — ever.

Systems Advanced

17  Threads

std::thread runs work on OS threads. spawn returns a handle; join blocks until the thread finishes and hands back its return value. move captures owned data into the closure.

Step 1 / 2

In double_in_thread, compute n * 2 on a spawned thread and return the joined result.

Hints
  • thread::spawn(move || n * 2) -- move takes ownership of n.
  • handle.join().unwrap() gives back the closure's return value.
17_threads.rs
Reset to starterCompiled in a sandbox; hidden checks must pass.
Reveal solution
use std::thread;

fn double_in_thread(n: i32) -> i32 {
    let handle = thread::spawn(move || n * 2);
    handle.join().unwrap()
}