Sponsored Content
Top Forums Programming creating multiple threads using single thread id Post 302496812 by Corona688 on Tuesday 15th of February 2011 10:39:55 AM
Old 02-15-2011
Quote:
Originally Posted by zing_foru
Hi all,

Can I create multiple threads using single thread_id
pthread_create does not take a thread ID, it overwrites the value of thread_id. That's why it's a pointer, you're telling it what memory to overwrite.

So you could create lots with the same variable, but you'd just be overwriting the same value every time and losing track of everything but the last created thread, not creating threads with the same ID.
 

8 More Discussions You Might Find Interesting

1. IP Networking

How to choose Multiple process or Multiple threads?

Hi All, Please explain me when i have to use multiple process and when I have to use Multiple threads? Please give me an example.It will be very helpful for me. Thanks in advance. (0 Replies)
Discussion started by: ashleykumar
0 Replies

2. IP Networking

Can we write a multiple thread to receive from a single socket file descriptor

Hi Friends, I have written a program which will listener for more than 1000 requests per second from a single socket descriptor and then it will process those requestes. Its taking X amount of time. Now i want to reduce that time. Will I can write multiple threads to receive the... (2 Replies)
Discussion started by: pa.chidhambaram
2 Replies

3. Solaris

Run in single thread

We're just migrating a large application from a Sun E6900 to T5440. One of the component parts is not playing, and despite a pretty detailed truss trace, it's not obvious why we're getting a SEGV fault! Just wondering if it's running multithreaded and the threads are getting mixed up, so 2... (1 Reply)
Discussion started by: JerryHone
1 Replies

4. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

5. Programming

Child threads communicating with main thread via pipes

I have a simple client/server program I am using for learning purposes. I have it setup so that after server is setup and listening it than goes into a loop where it accepts incoming client connections. After each connection, the client socket is than passed to a thread routine where it can be... (3 Replies)
Discussion started by: Majortom71
3 Replies

6. Shell Programming and Scripting

Creating single pattern for matching multiple files.

Hi friends, I have a some files in a directory. for example 856-abc 856-def 851-abc 945-def 956-abc 852-abc i want to display only those files whose name starts with 856* 945* and 851* using a single pattern. i.e 856-abc 856-def 851-abc 945-def the rest of the two files... (2 Replies)
Discussion started by: Little
2 Replies

7. UNIX for Advanced & Expert Users

How to kill a thread among several threads belongs to a process?

I would like to know is there any we can kill a single thread among multiple threads belongs to process? Since Signal action is process wise not per thread, i strongly feel that we can not or for that mater from external sources as well single thread can not be killed which is critical section... (2 Replies)
Discussion started by: murali242512
2 Replies

8. HP-UX

How to get number of threads for single java process on HP-UX OS?

Hi All, When i was trying to get total number of threads per java process using this command ps -o NLWP PID, I'm not getting any output. Could someone help me in this issue. Thanks, GMar (1 Reply)
Discussion started by: mgangumolu
1 Replies
pthread_create(3T)														pthread_create(3T)

NAME
pthread_create() - create a new thread of execution. SYNOPSIS
PARAMETERS
thread Pointer to the location where the created thread's ID is to be returned. attr Pointer to the thread attributes object describing the characteristics of the created thread. If the value is NULL, default attributes will be used. start_routine Function to be executed by the newly created thread. arg Parameter to be passed to the created thread's start_routine. DESCRIPTION
The function is used to create a new independent thread within the calling process. The thread will be created according to the attributes specified by attr. If attr is NULL, the default attributes will be used. The values of the attributes in attr describe the characteris- tics of the to-be-created thread in detail. Refer to the function for a list of the default attribute values. A single attributes object can be used in multiple calls to the function When a thread is created with an attributes object, the attributes are, in effect, copied into the created thread. Consequently, any change to the attributes object will not affect any previously created threads. Once all threads needing a specific attributes object have been created, the attributes object is no longer needed and may be destroyed. When the new thread is created, it will execute which has only one parameter, arg. If returns, an implicit call to is made. The return value of is used as the thread's exit status. The created thread's scheduling policy and priority, contention scope, detach state, stack size, and stack address are initialized accord- ing to their respective attributes in attr. The thread's signal mask is inherited from the creating thread. The thread's set of pending signals is cleared. Refer to pthread_exit(3T), pthread_detach(3T), and pthread_join(3T) for more information on thread termination and synchronizing with ter- minated threads. On success, the ID of the created thread is returned in thread. If fails, a thread is not created and the contents of thread are unde- fined. Thread IDs are guaranteed to be unique only within a process. NOTE: If the main thread returns from an implicit call to is made. The return value of is used as the process' exit status. The main thread can terminate without causing the process to terminate by calling Notes It is unspecified whether joinable threads that have exited but haven't been joined count against the limit. RETURN VALUE
Upon successful completion, returns zero. Otherwise, an error number is returned to indicate the error (the variable is not set). ERRORS
If any of the following occur, the function returns the corresponding error number: attr in an invalid thread attributes object. The value specified by thread is invalid. The necessary resources to create another thread are not available, or the number of threads in the calling process already equals The scheduling policy or scheduling attributes specified in attr are invalid. The caller does not have the appropriate privileges to create a thread with the scheduling policy and parameters specified in attr. AUTHOR
was derived from the IEEE POSIX P1003.1c standard. SEE ALSO
pthread_exit(3T), pthread_join(3T), fork(2). STANDARDS CONFORMANCE
Pthread Library pthread_create(3T)
All times are GMT -4. The time now is 02:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy