Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3670838
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:24:50+00:00 2026-05-19T02:24:50+00:00

So I have done some research, and have found you can create a boost::thread

  • 0

So I have done some research, and have found you can create a boost::thread object and have it start with a non-static class function by using “this” and boost::bind etc. It really doesn’t make much sense to me and all the examples I could find had the boost::thread object launched within the same class as the function it was starting with so this could be used. I however, am launching the thread in a different class so I’m afraid by using “this”, I will be saying the “this” is from the class I am creating the thread from, rather than the one the function is in (I’m probably wrong, I need to learn more about this “this” guy). Here is an example of my source I am having the problem with.

ANNGUI.h

class ANNGUI
{
private:
    boost::thread *GUIThread;
    Main *GUIMain;
public:
    // Creates the entire GUI and all sub-parts.
    int CreateGUI();
}

ANNGUI.cpp

int ANNGUI::CreateGUI()
{
        GUIMain = new Main();
    GUIThread = new boost::thread(GUIMain->MainThreadFunc);
};

This isn’t all the source, but I think my problem is in here somewhere, I know I have to deal with the “this” somehow, but I’m unsure how. I Could use a static function, but I didn’t really want to make my variables static either.
Thanks.

Also, Is there any very good resource for using any boost libraries? Their web site documentation seems good, but over my head.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:24:51+00:00Added an answer on May 19, 2026 at 2:24 am

    The this keyword is used with boost::bind when the function object you’re creating is bound to a object member function. Member functions can’t exist apart from instances, so when creating a functor object out of a member function with boost::bind, you need a pointer to an instance. That’s exactly what the this keyword actually is. If you use the this keyword within a member function of a class, what you get is a pointer to the current instance of that class.

    If you were to call bind from outside a class member function, you might say something like:

    int main()
    {
      Foo f;
      boost::thread* thr = new boost::thread(boost::bind(&Foo::some_function, &f));
    }
    

    Here, we’re using Foo::some_function as our thread function. But we can’t use this because we’re calling bind from main. But the same thing could be achieved using this if we called bind from within a member function of Foo, like so:

    void Foo::func1()
    {
      boost::thread* thr = new boost::thread(boost::bind(&Foo::some_function, this));
    }
    

    If a member function is static, or is simply a regular (non-member) function, then you don’t need an instance pointer at all. You would just do:

    boost::thread* thr = new boost::thread(some_regular_function);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've done some research into server push with javascript and have found the general
I have done some research on this subject, and found out, that Gzipping and
So I have done some research and found out that MongoDB doesn't do fsync(),
I'm working on key handling in Javascript. I have done some research and I'd
I have done some searches looking for information about how to do logging with
I've done some Python but have just now starting to use Ruby I could
Traditionally, when we use SQL string to done some work, we have to close
Has anyone done this / have some example code?
I have done a bit of research into this and it seems that the
i have a input tag which is non editable, but some times i need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.