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

  • SEARCH
  • Home
  • 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 7869189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:14:19+00:00 2026-06-03T01:14:19+00:00

My question is regarding the values ​​passed in when creating an object. Making debugging,

  • 0

My question is regarding the values ​​passed in when creating an object.
Making debugging, it is clear that the values ​​of ‘id’, ‘cont’, ‘size’ and ‘nthreads’ get lost somehow.
I searched the internet and found the link https://stackoverflow.com/questions/1151582 teaching how to pass an object and make a method call him.
It works until the method ‘run ()’, where the values ​​passed when creating the object are lost.
I do not know if I need to mess with static types so that it does not, however, I am not knowing what to do.

class Section1SimpleBarrierThread {

 Section1SimpleBarrierThread(int id, Section1Counter* cont, int size, int nthreads) {
        this->id = id;
        this->cont = cont;
        this->size = size; 
        this->nthreads = nthreads;
  }

  void* run(void){
    pthread_mutex_lock(&mutex);
    for(int i=0; i<size; i++) {
       cont->shared_cont++;
       if(cont->shared_cont != this->nthreads) {
         //cont.wait();
       } else {
          //cont->shared_cont = 0;
          // cont.notifyAll();
       }  
   }
   pthread_mutex_unlock(&mutex);
  }

  static void* run_helper(void* context){
     return ((Section1SimpleBarrierThread*)context)->run();
  }  
};

while ( (time < TARGETTIME) && (size < MAXSIZE) ){     
j->resetTimer("Section1:Barrier:Simple"); j->startTimer("Section1:Barrier:Simple");

for(int i=0; i<nthreads; i++) { 
thobjectsSimpleBarrierThread[i]= new Section1SimpleBarrierThread(i,cont,size,nthreads);
pthread_create(&thread_id[i],NULL,&Section1SimpleBarrierThread::run_helper,&thobjectsSimpleBarrierThread[i]);

for(int i=0; i<nthreads; i++) {
        pthread_join(thread_id[i],NULL);
    }
}
  • 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-03T01:14:21+00:00Added an answer on June 3, 2026 at 1:14 am

    ‘&thobjectsSimpleBarrierThread[i]’ – where is this array, and what is its type. The ‘&’ operator here looks very suspicious… Surely thobjectsSimpleBarrierThread already a pointer type because you new()ed it on the line above!

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

Sidebar

Related Questions

I'm learning JS here, and have a question regarding primitive values when passed in
Question regarding fluent nHibernate table mappings: Apparently I was under the mistaken impression, that
I have a question regarding static function in php. let's assume that I have
I have a general question - regarding testing of values, I have run into
I'm just learning about generics and have a question regarding method return values. Say,
With reference to the question regarding replicating values from one textbox to another Replicating
bit of noob question regarding .Net and C#. I have a function that registers
I have a question regarding the most efficient way to design a class that
simple question regarding property value inheritance in UserControls. If i create a UserControl, it
Question regarding GtkBuilder. When we unref builder pointer does it destroys all the screens/widgets

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.