Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

compiling a C++ on linux with gcc-3.2.2

Posted on 2003-03-02
4
Medium Priority
?
160 Views
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?
stephen
0
Comment
Question by:zollen
  • 2
  • 2
4 Comments
 
LVL 8

Expert Comment

by:akshayxx
ID: 8054256
show the code ..
0
 

Author Comment

by:zollen
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....

stephen
0
 

Author Comment

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

stephen
0
 
LVL 8

Accepted Solution

by:
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

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Integration Management Part 2
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month12 days, 12 hours left to enroll

579 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