Thread synchronization

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Giulio Petrucci

    Thread synchronization

    Hi there,

    I have two threads:
    - thread A: write some data into a stream (audio on an audio card,...etc...)
    - thread B: listen for an event (mouse click,...)
    I need to stop A when the event B's listening to occures.

    Please, could anyone help me?

    Thanks in advance,
    Giulio - Italia
  • PokerMan

    #2
    Re: Thread synchronization

    Maybe i have misunderstood, but i presume an event fires that tells Thread B
    to start? And you want Thread A to stop when thread B starts? So stop Thread
    A when the event that triggers B to start fires? have i misunderstood you
    here?

    Also if they will not run simulatenously, why the need to run them on
    separate threads in the first place?

    "Giulio Petrucci" <fakename@faked omain.comwrote in message
    news:eyIST0yXHH A.4868@TK2MSFTN GP03.phx.gbl...
    Hi there,
    >
    I have two threads:
    - thread A: write some data into a stream (audio on an audio
    card,...etc...)
    - thread B: listen for an event (mouse click,...)
    I need to stop A when the event B's listening to occures.
    >
    Please, could anyone help me?
    >
    Thanks in advance,
    Giulio - Italia

    Comment

    • Bruce Wood

      #3
      Re: Thread synchronization

      On Mar 5, 5:49 am, Giulio Petrucci <faken...@faked omain.comwrote:
      Hi there,
      >
      I have two threads:
      - thread A: write some data into a stream (audio on an audio card,...etc...)
      - thread B: listen for an event (mouse click,...)
      I need to stop A when the event B's listening to occures.
      Have B's event listener set a boolean flag in the object that contains
      the code for A. Then have A poll (test) the flag at regular intervals,
      say before each write.

      If A finds that the flag is true, then it should abort.

      Comment

      • Giulio Petrucci

        #4
        Re: Thread synchronization

        Hi PokerMan,

        PokerMan ha scritto:
        Maybe i have misunderstood, but i presume an event fires that tells Thread B
        to start?
        Maybe. ;-)
        Also if they will not run simulatenously, why the need to run them on
        separate threads in the first place?
        Because they're using currently two different HW resources.

        Bye,
        Giulio

        --

        Comment

        • Giulio Petrucci

          #5
          Re: Thread synchronization

          Hi Bruce,

          Bruce Wood ha scritto:
          Have B's event listener set a boolean flag in the object that contains
          the code for A. Then have A poll (test) the flag at regular intervals,
          say before each write.
          I see.
          So the only way is to use a buffer for writing data.

          Thanks for your suggestion!
          Giulio - Italia

          --
          OnAir: nothing but the bus passing in the street

          Comment

          Working...