Recent

Author Topic: Sleep  (Read 395 times)

scasparz

  • Jr. Member
  • **
  • Posts: 52
Sleep
« on: June 12, 2022, 05:05:02 pm »
Am Linux Mint running the latest Lazarus.

Just a simple question: have an application running a number of threads, that seem to work well.
Of course calling tthread.Sleep will put the corresponding thread to sleep.
However, calling Sleep on the main thread does this mean that both the main thread as well the child threads are placed to sleep as well?


kind regards
s

Red_prig

  • Jr. Member
  • **
  • Posts: 66
Re: Sleep
« Reply #1 on: June 12, 2022, 05:16:08 pm »
No, it only puts to sleep the thread in which the function is called.

MarkMLl

  • Hero Member
  • *****
  • Posts: 5239
Re: Sleep
« Reply #2 on: June 12, 2022, 05:51:29 pm »
Note that Sleep() works at the OS kernel level, while a TTimer etc. works at the GUI level.

I'd also note that it's bad form to put any sort of kernel-level delay or blocking call in the main (GUI) thread, since it will prevent the message loop from running and leave the user interface unresponsive.

The fact that you're asking about threads suggests that you've already got fairly good ideas how to work round that sort of thing :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018