#I need help with understanding Send marker

2 messages · Page 1 of 1 (latest)

merry scaffold
#

spawn requires that the closure you pass it has 'static lifetime since the thread can keep running upto the termination of the program....to borrow from shorter lived data you can look at https://doc.rust-lang.org/std/thread/fn.scope.html

That joins all spawned threads using the scope when the closure exits (and blocks the main thread until the scope call is finished - all threads are joined)

meager pier
#

spawn requires Send and 'static for the function; it's not enough to have just one of the two. These are two separate requirements that don't particularly interact with each other.