Thread: Another newbie question

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    25

    Another newbie question

    Is there a way to make a function run "in the background" ?

    like this:

    myFunction(); //this will run til the app closes..
    AnotherFuntion(); //while myFucntion is still running..

    Hope you understand what i mean.
    Is this possible?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Certainly.......you need to create a thread.....Look up some tutorials

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    25
    Thanks...

    When u say threads do u mean like this?

    loop (indeed)
    {
    function();
    {
    anotherFunction();
    }
    }

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    nope......

    In you example, the code in function() is executed before anotherfunction()............so anotherfunction() must wait for function() to complete before its executed........

    With threads they execute at the same time.......

  5. #5
    Registered User
    Join Date
    Jun 2002
    Posts
    29
    It's interesting problem, for example I want to have a timer running in background and another things..
    I heard something about threads, but I don't know how to use them.. do you know where is some tutorial about that?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Newbie question
    By TimL in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2008, 04:43 AM
  2. C prog newbie question
    By Draginzuzu in forum C Programming
    Replies: 1
    Last Post: 02-03-2003, 06:45 PM
  3. a stupid question from a newbie
    By newcomer in forum C++ Programming
    Replies: 4
    Last Post: 01-11-2003, 04:38 PM
  4. confusion with integers (newbie question)
    By imortal in forum C Programming
    Replies: 7
    Last Post: 12-06-2002, 04:09 PM
  5. newbie class templates question
    By daysleeper in forum C++ Programming
    Replies: 2
    Last Post: 09-18-2001, 09:50 AM