compiling a C++ on linux with gcc-3.2.2

Posted on 2003-03-02
Medium Priority
Last Modified: 2010-04-21
I use the following commands to compile my program

g++ -I./ testme.cpp Thread.o -lpthread -lm -lieee

Basically, the main program creates 5 threads and each thread supposes to print out a "hello world" statement. However the main program cannot create all 5 threads for some unknown reason......

Any idea?
Question by:zollen
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Expert Comment

ID: 8054256
show the code ..

Author Comment

ID: 8054682

pthread_create (thr, NULL, StartRoutine,....);

StartRoutine() is a function invoked in a child thread. The only thing it does is to print out "hello world". I created 5 threads but I see only 2-4 "hello world" statements on my screen....


Author Comment

ID: 8054687
Is is possible that additional compiler options are required??


Accepted Solution

akshayxx earned 200 total points
ID: 8054723
ur main program is dying out before all other threads finish up.. so there are two ways
once u r finished up doing creation of threads .. do join on each thread.. then it will ensure that ur main program will wait for the threads to finish up their jobs..
look at the usage of pthread_join

in the end of creation of all threads .. and other jobs .. just before ur return statement of main{}
write this
this will suspend ur main thread ..and to close ur program use ctrl-C

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question