lib.rs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2006-2025, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author notes
  8. * 2025-10-10 foxglove thread test demo
  9. * 2025-10-29 foxglove Updated to demonstrate new modular macro interface
  10. */
  11. #![no_std]
  12. use core::time::Duration;
  13. use rt_macros::msh_cmd_export;
  14. use rt_rust::param::Param;
  15. use rt_rust::println;
  16. use rt_rust::thread;
  17. use rt_rust::time;
  18. #[msh_cmd_export(name = "rust_thread_demo", desc = "Rust example app.")]
  19. fn main(_param: Param) {
  20. let _ = thread::Thread::new()
  21. .name("thread 1")
  22. .stack_size(1024)
  23. .start(move || {
  24. loop {
  25. println!("thread a will sleep 1s");
  26. time::sleep(Duration::new(1, 0));
  27. }
  28. });
  29. let _ = thread::Thread::new()
  30. .name("thread 2")
  31. .stack_size(1024)
  32. .start(move || {
  33. loop {
  34. println!("thread b will sleep 3s");
  35. time::sleep(Duration::new(3, 0));
  36. }
  37. });
  38. }