#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    25
    Rep Power
    0

    Multiple threads


    I would like to press one button to fire several timed actions simultaneously. Each action will then run and end seperately according to its own code. I believe it could be done with BeginThread etc. Any idea how? Just designing some sort of game
  2. #2
  3. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    2
    Rep Power
    0

    Multiple threads


    I/O and scheduling

    User thread or fiber implementations are typically entirely in userspace. As a result, context switching between user threads or fibers within the same process is extremely efficient because it does not require any interaction with the kernel at all: a context switch can be performed by locally saving the CPU registers used by the currently executing user thread or fiber and then loading the registers required by the user thread or fiber to be executed. Since scheduling occurs in userspace, the scheduling policy can be more easily tailored to the requirements of the program's workload.

    However, the use of blocking system calls in user threads (as opposed to kernel threads) or fibers can be problematic. If a user thread or a fiber performs a system call that blocks, the other user threads and fibers in the process are unable to run until the system call returns. A typical example of this problem is when performing I/O: most programs are written to perform I/O synchronously. When an I/O operation is initiated, a system call is made, and does not return until the I/O operation has been completed. In the intervening period, the entire process is "blocked" by the kernel and cannot run, which starves other user threads and fibers in the same process from executing.

    <Mod edit: I'm keeping this reply, even though the poster is a no-good seo scum who is merely looking to increase his post count. FYI, he cut and pasted his reply from wikipedia on Threads and probably has no idea what he's talking about.>
    Last edited by Scorpions4ever; April 19th, 2013 at 04:12 PM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    25
    Rep Power
    0

    Multiple threads


    Thank you for your technical answer which, unfortunately I don't really quite understand
    Still, is there a simple solution?
    I have four lights and currently, each one will only go on after each other, albeit microseconds, but still it is not instant.
    Can I put them ALL on simultaneously?


    Originally Posted by bullsforex
    I/O and scheduling

    User thread or fiber implementations are typically entirely in userspace. As a result, context switching between user threads or fibers within the same process is extremely efficient because it does not require any interaction with the kernel at all: a context switch can be performed by locally saving the CPU registers used by the currently executing user thread or fiber and then loading the registers required by the user thread or fiber to be executed. Since scheduling occurs in userspace, the scheduling policy can be more easily tailored to the requirements of the program's workload.

    However, the use of blocking system calls in user threads (as opposed to kernel threads) or fibers can be problematic. If a user thread or a fiber performs a system call that blocks, the other user threads and fibers in the process are unable to run until the system call returns. A typical example of this problem is when performing I/O: most programs are written to perform I/O synchronously. When an I/O operation is initiated, a system call is made, and does not return until the I/O operation has been completed. In the intervening period, the entire process is "blocked" by the kernel and cannot run, which starves other user threads and fibers in the same process from executing.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    356
    Rep Power
    7
    Originally Posted by sihaam
    I have four lights and currently, each one will only go on after each other, albeit microseconds, but still it is not instant.
    Can I put them ALL on simultaneously?
    The short answer to your question is no..

    The reason is that only the MAIN thread of your application can manipulate the application's GUI. So if you were to create several threads to accomplish this task, each thread would have to synchronize with the main thread to make changes to the GUI, putting you right back where you started.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    25
    Rep Power
    0

    Multiple threads


    Actually I found a free, simple yet dynamic component to do this job for me. Multi threading is a breeze.

    http://www.torry.net/vcl/system/threads/BMDThread.zip



    Originally Posted by majlumbo
    The short answer to your question is no..

    The reason is that only the MAIN thread of your application can manipulate the application's GUI. So if you were to create several threads to accomplish this task, each thread would have to synchronize with the main thread to make changes to the GUI, putting you right back where you started.

IMN logo majestic logo threadwatch logo seochat tools logo