feat: completed solutions
This commit is contained in:
@@ -17,18 +17,23 @@ impl Queue {
|
||||
fn send_tx(q: Queue, tx: mpsc::Sender<u32>) {
|
||||
// TODO: We want to send `tx` to both threads. But currently, it is moved
|
||||
// into the first thread. How could you solve this problem?
|
||||
|
||||
let transmission = tx.clone();
|
||||
|
||||
thread::spawn(move || {
|
||||
for val in q.first_half {
|
||||
println!("Sending {val:?}");
|
||||
tx.send(val).unwrap();
|
||||
transmission.send(val).unwrap();
|
||||
thread::sleep(Duration::from_millis(250));
|
||||
}
|
||||
});
|
||||
|
||||
let transmission = tx.clone();
|
||||
|
||||
thread::spawn(move || {
|
||||
for val in q.second_half {
|
||||
println!("Sending {val:?}");
|
||||
tx.send(val).unwrap();
|
||||
transmission.send(val).unwrap();
|
||||
thread::sleep(Duration::from_millis(250));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user