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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

need help with threads

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
ashi2
Asked:
ashi2
  • 4
  • 2
  • 2
  • +3
1 Solution
 
bobbit31Commented:
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
 
bobbit31Commented:
sorry, wrong thread ;)
0
 
Kent OlsenData Warehouse Architect / DBACommented:

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
Independent Software Vendors: 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!

 
peter_sheynkmanCommented:
Seems like you forgot the '=' sign before zero inside the if statemant
0
 
eranborovikCommented:
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
 
ashi2Author Commented:
hi need to be done in c
0
 
Kent OlsenData Warehouse Architect / DBACommented:

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

0
 
Kent OlsenData Warehouse Architect / DBACommented:

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


sigh....
0
 
ashi2Author Commented:
don't worry, I finihed working on it, is working perfect
0
 
Kent OlsenData Warehouse Architect / DBACommented:
Hey Ashi,

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


0
 
jmcgOwnerCommented:
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

Technology Partners: 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!

  • 4
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now