?
Solved

need help with threads

Posted on 2003-03-10
12
Medium Priority
?
257 Views
Last Modified: 2010-04-15
Hello,

I need some help with creating pthreads, i worte following code to make 5threads

#define NUM_THREAD 5

pthread_t local_tID[5];

/* create 5 threads and then in a while accept connections */
pb = pqueueinit(10);

for(i = 0; i < NUM_THREAD; i++)
{
if( (pthread_create(&local_tID[i], NULL, (void *)threadWord, (void *)pb))!0) {
   fprintf(stderr, "Couldnt create a thread\n");
   exit(1);
  }
}

some sort of this is to be insert in my original function, i did with 2thread but could not do with 5 thread.

need help


0
Comment
Question by:ashi2
[X]
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
  • 4
  • 2
  • 2
  • +3
12 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 8108255
HOWEVER, you can use javascript to do it:

<html>

<head><script LANGUAGE="vbscript">
<!--
Dim WshSHell
set WshShell = CreateObject("WScript.Shell")
WshShell.Run("notepad.exe")
-->
</script>

although MOST people will have their security settings set to disallow this.
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 8108258
sorry, wrong thread ;)
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 8108347

A thread is a thread.  If you can create 2 then you're very close to creating 5.

If pthread_create() fails, display the error code as part of the message.  Odds are it'll tell you everything that you want to know.


Kdo
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Accepted Solution

by:
peter_sheynkman earned 80 total points
ID: 8109434
Seems like you forgot the '=' sign before zero inside the if statemant
0
 

Expert Comment

by:eranborovik
ID: 8117471
Please show with what libraries and what preprocessor
defines you link and compile your files. Omitting
a flag in compilation might be the cause. For
example, In solaris you must compile with the lpthread
library and add the -mt flag to the command line argument
passed for each file compilation.
 
0
 

Author Comment

by:ashi2
ID: 8129653
hi need to be done in c
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 8130578

Peter nailed it.  The second "if" statement need help.

0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 8131382

Second?  Second?  How the hell can I help anyone if I can't count to one?


sigh....
0
 

Author Comment

by:ashi2
ID: 8133796
don't worry, I finihed working on it, is working perfect
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 8133862
Hey Ashi,

"Don't Worry" is the wrong answer -- Peter deserves some credit here.


0
 
LVL 20

Expert Comment

by:jmcg
ID: 10105177
Nothing has happened on this question in more than 9 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by peter_shenynkman.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Suggested Courses

777 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