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 7835781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:48:17+00:00 2026-06-02T13:48:17+00:00

I am instantiating multiple instance of a class that creates a thread. Since threads

  • 0

I am instantiating multiple instance of a class that creates a thread. Since threads are static, will the instances of the object interfere with each other’s thread operation?

Oddly I see 2 different waveforms and running at two different Sleep delays. ??? so does this mean there are 2 different threads ???

void CWaveGeneration::CreateWave()
{

    Y = new double[numPoints];
    X = new double[numPoints];
    I = new int[numPoints];


    CWaveGeneration *pp = this;
    hThread_Wave = CreateThread(NULL, 0, Thread_Wave, pp, 0, NULL); 
    //within the thread, there is the setting of Sleep(iSleep);
}


void CWaveGeneration::CreateWave(int _waveType, double _A, double _w, double _T, double _r, int _numPoints, int _iSleep)
{
    waveType = _waveType;
    A = _A;
    w = _w;
    T = _T;
    r = _r;
    numPoints = _numPoints;
    iSleep = _iSleep;

    CreateWave();
}


DWORD WINAPI CWaveGeneration::Thread_Wave(LPVOID iValue)
{
    CWaveGeneration *p = (CWaveGeneration*)iValue;
    switch (p->waveType)
    {
    case 0:
        p->Sine();
        break;
    case 1:
        p->Square();
        break;
    case 2:
    //  p->Triangle();
        break;
    case 3:
    //  p->SawTooth();
        break;
    }

    return true;
}

from the header file:

static DWORD WINAPI Thread_Wave(LPVOID iValue);

    wave1 = new CWaveGeneration();
    wave1->CreateWave(0,100,10,0,0,200, 10);

    wave2 = new CWaveGeneration();
    wave2->CreateWave(1,80,5,0,0,200, 100);

    // in total, are there 1 thread or 2 threads created here ???
  • 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-06-02T13:48:18+00:00Added an answer on June 2, 2026 at 1:48 pm

    If the thread object in your class is static, then you will have only one thread for all the instances of the class.
    If the thread object in the class is not static, then each instance of the class will have 1 thread object.This should not have any problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main form that has multiple buttons on it that will allow
I am instantiating and sending multiple instances of HTTPService On a Mac, however, many
When Instantiating a class, Windsor by default treats all public properties of the class
I am working with Active Directory using C#. Instantiating the PrincipalContext object seems to
I'm reading a book about DI that always talks about DI frameworks instantiating an
It's really irking me that PHP considers the failure to instantiate an object a
I'd like to create an instance of a class using unity where the class
In my project, say I am instantiating a class named SubClass , which extends
I understand that multiple inheritance 1 is simply not supported in PHP, and while
I have a few separate application projects (EARs) with multiple EJBs that I want

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.