use std::thread;
use tokio::task::LocalSet;
use tokio::runtime::Builder;
fn main() {
thread::spawn(move || {
let local = LocalSet::new();
let rt = Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
rt.block_on(local.run_until(async {
let task = tokio::task::spawn_local(async {
//何かしらの処理
});
let _ = task.await;
}));
});
}
とfn main() {
thread::spawn(move || {
let local = tokio::task::LocalSet::new();
local.spawn_local(async move {
// 何かしらの処理
});
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(local);
});
}
の、threadの観点での違いを理解したい