CN102117222A - Multi-thread starting method - Google Patents

Multi-thread starting method Download PDF

Info

Publication number
CN102117222A
CN102117222A CN2010100015102A CN201010001510A CN102117222A CN 102117222 A CN102117222 A CN 102117222A CN 2010100015102 A CN2010100015102 A CN 2010100015102A CN 201010001510 A CN201010001510 A CN 201010001510A CN 102117222 A CN102117222 A CN 102117222A
Authority
CN
China
Prior art keywords
function
thread
class
base class
pthread
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN2010100015102A
Other languages
Chinese (zh)
Inventor
薛永胜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alcatel Lucent SAS
Original Assignee
Lucent Technologies Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Lucent Technologies Inc filed Critical Lucent Technologies Inc
Priority to CN2010100015102A priority Critical patent/CN102117222A/en
Publication of CN102117222A publication Critical patent/CN102117222A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses a multi-thread starting method, which comprises the following steps of: creating a base class, wherein the base class comprises a thread creation function and a running function as an import function of a thread created by the thread creation function, and a parameter of the running function defines the type of a virtual function; reloading the virtual function of the base class according to the functions of each thread to be started, and generating each of a plurality of derived classes of the base class; and starting the thread by calling the thread creation function in the base class and taking the reference of the derived class as the parameter of the running function.

Description

Multithreading startup method
Technical field
The present invention relates to start in the Object oriented programming environment method of thread, more specifically, relate to a kind of multithreading startup method in the Object oriented programming environment.
Background technology
In recent years, the scale of program is orientated extensiveization gradually in software development, and for this reason, object oriented language maintainable and that usability is good again is noticeable.Object oriented language is meant a kind of language, the action of its description object, and action and this group of objects of object described as program altogether.And object is meant data and operates the process of these data (method) by the integrated unit that forms.Object oriented language includes for example C++.C++ is the programming language that has added the support of object based programming on the basis of processor-oriented programming language " C ".C++ has obtained reinforcement than the various functions of C.
But because C Plus Plus just is designed for single-threaded programmed environment at first, so multi-thread mechanism was adding in the C Plus Plus as the storehouse afterwards.
Current, the establishment thread need use the pthread_create () built-in function in the thread library.Below be function prototype and the functional description of pthread_create (), this handbook comes from solaris9, can obtain with " man pthread_create ".
int?pthread_create(pthread_t*thread,const?pthread_attr_t*attr,void*(*start_routine,void*),void*arg);
Figure G2010100015102D00011
Thread: thread id.[output parameter]
Figure G2010100015102D00012
Attr: the attribute of given thread [input parameter]
Figure G2010100015102D00013
Start_routine: the inlet of thread [input parameter]
Figure G2010100015102D00014
Arg: the address of variable of entrance function start_routine [input parameter]
Illustrate:
Pthread_create () function is used for creating new thread in process, and this thread has the attribute by the attr regulation.If attr is empty, then use default attribute.(referring to pthread_attr_init (3THR)).Even later stage modify the attribute of attr defined, the attribute of thread can not change yet.After completing successfully thread, pthread_create () is at the ID of the position storage thread of creating that thread quoted.
The establishment of thread is to carry out start_routine with arg as unique variable.The result that start_routine returns uses the rreturn value of start_routine as exit status, has implicitly called pthread_exit () built-in function.This is different with the main thread that invokes thread is created the principal function main () of function.In main () function, when when main () returns, effect similarly is to use the rreturn value of main () as exit status, has implicitly called exit ().
Pthread_create () requires the function of a c type as its parameter s tart_routine (), and general arg normally is delivered to c type of functions start_routine () as a General Parameters.
Therefore, current, start thread as follows:, write out the independently entrance function of C type at every thread.These functions will be as start_routine ().
But, starting at needs under the situation of a plurality of similar threads, the programming personnel must write out the entrance function separately of a plurality of threads, so workload is big, and the program structure of writing out is clear inadequately, is difficult to safeguard and read.
Following code shows the existing method that five threads of function sleep consuming time (10) are carried out in establishment simultaneously:
/*cc?thisfile.c-lthread-lpthread*/ #define_REENTRANT/*basic?3-lines?for?threads*/ #include<pthread.h> #include<thread.h> #define?NUM_THREADS?5 #define?SLEEP_TIME?10 void*sleeping(void*);/*thread?routine*/ int?i; thread_t?tid[NUM_THREADS];/*array?of?thread?IDs*/ int
main(int?argc,char*argv[]){ if(argc==1){ printf(″use?0as?arg?1?to?use?pthread_create()\n″); printf(″or?use?1?as?arg?1?to?use?thrcreate()\n″); return(1); } switch(*argv[1]){ case′0′:/*POSIX*/ for(i=0;i<NUM_THREADS;i++) pthread_create(&tid[i],NULL,sleeping, (void*)SLEEP_TIME); for(i=0;i<NUM_THREADS;i++) pthread_loin(tid[i],NULL); break; case′1′:/*Solaris*/ for(i=0;i<NUM_THREADS;i++) thr_create(NULL,0,sleeping,(void*)SLEEP_TIME,0, &tid[i]); while(thr_join(NULL,NULL,NULL)==0); break; }/*switch*/ printf(″main()reporting?that?all%d?threads?have?terminated\n″,i); return(0);}/*main*/void*sleeping(void*arg){ int?sleep_time=(int)arg; printf(″thread%d?sleeping?%d?seconds...\n″,thr_self(),sleep_time); sleep(sleep_time); printf(″\nthread%d?awakening\n″,thr_self()); return(NULL);}
Summary of the invention
In OO technology, be model with the real world objects, " object " that the definition computing machine can emulation.The method of object and attribute are defined by " class ".Class definition total method and the attribute in the object.
Class can be inherited.Inherit all function performances that had heritable parent in the derived class of a class.If the function of a function needs to change, then can utilize polymorphic characteristic, be virtual function with this function definition of parent, and in derived class, its function rewritten.When calling this function in object, compiler decides according to the type of object and calls which function.Particularly, if to as if base class sub-object, will call that function in the base class, if object actual be the derived class object, will call that function in the derived class.Which call function and be by the actual type decision of function.
Therefore, the present inventor recognizes, under the situation that will start a plurality of threads, can make up a base class, total parameter and the function of each thread of definition in base class utilizes the function of C++ to inherit and polymorphic characteristic, also defining virtual function in base class simultaneously, in the derived class of this base class, virtual function is carried out heavy duty with convenient, thereby the different piece to each thread defines in derived class.By (start_routine arg) and the parameter " arg " of start_routine (arg), starts these threads for id, attr as pthread_create with the object of derived class.Like this, the user is no longer necessary for the whole entry code that each thread that will start repeats to write a thread entrance function.At each thread, the user only need be in derived class by to the virtual function heavy duty, write out the function of the work that need do about this thread, and the total work of a plurality of threads is transferred to base class and is finished, and no longer need repeat in each thread.Like this, saved the procedure quantity that the programming personnel need programme, and the program structure of writing out is clear, safeguards simple and be convenient to and read.
The present invention only pays close attention to the startup of thread, and and how to be indifferent to management thread, for example be provided with priority, this thread of initialization of thread proprietary data, the stack size is set, range of operation etc. is set.
According to a scheme of the present invention, a kind of multithreading startup method has been proposed, comprise step: create base class, described base class comprises the thread creation function and as the operation function of the entrance function of thread creation thread that function is created, described operation function comprises virtual function, a parameter-definition of described operation function the type of virtual function; According to the function of each thread that will start, the virtual function of base class is carried out heavy duty, produce in a plurality of derived class of base class each; And by calling thread creation function in the base class, and will starting this thread to the quoting of derived class as described operation function parameters.
Preferably, the operation function in the base class comprises the common function of a plurality of threads that will start.
Preferably, described thread entrance function is converted into and meets the type that the thread creation function requires the thread entrance function type.
Preferably, described method is applied in the Object oriented programming environment.
Preferably, described Object oriented programming environment is the C++ programmed environment.
Preferably, to quoting of derived class be the address of derived class.
Preferably, described thread creation function is pthread_create () function.
Multithreading startup method according to the present invention has been created a base class that can conveniently start multithreading, can be achieved as follows technique effect based on this base class:
1) is reduced at the method that starts a plurality of threads in the C++ programming;
2) application of convenient expansion different threads;
3) provide a simple and easy pattern: be used for using the C type of functions, make structured programming more clear at C++.
Description of drawings
Fig. 1 shows according to the graph of a relation between each class of test sample of the present invention, and has described the composition of each class briefly; And
Thread called in proper order when Fig. 2 showed according to the startup multithreading of test sample of the present invention; And
Fig. 3 shows the process flow diagram according to the multithreading startup method of test sample of the present invention.
Embodiment
Below, the present invention is described with reference to the accompanying drawings.In the following description, some specific embodiments only are used to describe purpose, and should not be construed the present invention are had any restriction, and are example of the present invention.
The method according to this invention has been utilized the following characteristic of Object oriented programming environment:
1) succession and polymorphic;
2) conversion of static class function and type of functions (typecast);
3) regime type is judged.
As the example of Object oriented programming environment the present invention is described with C++ below.Obviously, thought of the present invention is applicable under any other Object oriented programming environment with above-mentioned characteristic.
The method according to this invention in order to start a plurality of threads, needs to make up a base class and a plurality of derived class.
For convenience of description, introduce 3 classes here, a base class ThreadBase and two derived class, these two derived class are corresponding to two threads that will start.The composition of each class is described below.
Figure G2010100015102D00061
Base class ThreadBase comprises:
◆ member's data comprise:
◇ is about the total attribute data of thread: thread attribute and Thread Id;
◆ member function (method) comprises:
◇ virtual init (par1, par2, ...): thread attribute attr data are carried out initialization, with its be defined as virtual function be for its inherit subclass can be when realizing the initialization data relevant with own task, thereby this part data should define in the succession subclass;
◇ virtual run (): the definition of executing the task, it is defined as virtual function is to inherit the operation function run () that subclass has own version for each;
◇ static void*startRoutine (void*arg): with the thread entrance function of arg as parameter, this function will call arg->run () execution thread task;
◇ int startThread (): this function is used to start thread, and thread entrance function is startRoutine.
Figure G2010100015102D00062
Derived class ThreadDerivedA (the derived class A of base class ThreadBase):
◆ member's data comprise:
The data member of ◇ base class: thread attribute and Thread Id; And
The additional data of ◇ self;
◆ member function (method) comprises:
◇ virtual init (par1, par2 ...): the specific implementation of the init () of base class;
◇ virtual run (): the specific implementation of the operation function run () of base class;
◇ static void*startRoutine (void*arg): with the thread entry of arg as parameter, this function will call arg->run () execution thread task;
◇ int startThread (): this function is used to start thread.
Derived class ThreadDerivedB (the derived class B of base class ThreadBase):
◆ member's data comprise:
Member's data of ◇ base class: thread attribute and Thread Id; And
The additional data of ◇ self;
◆ member function (method) comprises:
◇ virtual init (par1, par2 ...): the specific implementation of the init () of base class;
◇ virtual run (): the specific implementation of the operation function run () of base class;
◇ static void*startRoutine (void*arg): with the thread entry of arg as parameter, this function will call arg->run () execution thread task;
◇ int startThread (): this function is used to start thread.
Here, introduce a test sample.
Test class ThreadApplication:
◆ member's data comprise:
The object of ◇ ThA:ThreadDerivedA;
The object of ◇ ThB:ThreadDerivedB;
◆ member function comprises:
◇ startAll (): the function that such will be realized: by calling ThA.startThread () and ThB.startThread (), start two threads, the type of these two threads is respectively ThreadDerivedA and ThreadDerivedB.
Following code shows the multithreading startup method according to test sample of the present invention:
#ifndef_THREAD_B_SAE_H #define_THREAD_B_SAE_H #include<iostream.h> #include<pthread.h>
#include<signal.h〉#include<string.h〉using namespace std; #ifdef_cplusplus/{ #endif typedef void* (* routineType) (void*) for * forced type conversion */extern " C "; #ifdef_cplusplus } #endif class ThreadBase/* establishment base class */{ public:ThreadBase (); Virtual~ThreadBase (); Virtual int init (); Virtual int run (); Int startThread (); Static void*startRoutine (ThreadBase*thr); / * other accessor and mutator to access/write * the data members of the thread, such like:*pthread_Id, pthread_attributes * */inline void setThreadId (pthread_t tid) { threadId=tid; Inline pthread_t getThreadId () { return threadId; Inline void setThreadAttr (pthread_attr_t﹠attr) { threadAttr=attr; Void pthread_attrt﹠getThreadAttr () { return﹠threadAttr; Private:pthread_t threadId; Pthread_attr_t threadAttr; ; ThreadBase::ThreadBase (): threadId (0) { } ThreadBase: :~ThreadBase ()
{ if(threadId>0) { pthread_kill(threadId,SIGKILL); threadId=0; }}int ThreadBase::init(){return 0;}int ThreadBase::run(){return 0;}void*ThreadBase::startRoutine(ThreadBase*thr){ thr->run(); /*User should define the return status in the derived classes,thencheck the status through thr->getRet().thris returned as a whole totake any exit status saved in the object*/ return static_cast<void*>(thr);}intThreadBase::startThread(){ int ret=-1; init(); pthread_attr_init(&threadAttr); ret =pthread_create(&threadId,&threadAttr,reinterpret_cast<routineType>(startRoutine),(void*)this); cout<<″ret=″<<ret<<endl; pthread_attr_destroy(&threadAttr); setThreadId(ret); return ret;}#endif
#ifndef_THREAD_DERIVEDA_H #define_THREAD_DERIVEDA_H #include″ThreadBase.h″ #include<iostream.h> using?namespace?std;
//using std::cout; //using std::cin; //using std::endl; Class ThreadDerivedA:public ThreadBase/* creates derived class */{ public:ThreadDerivedA ();~ThreadDerivedA (); Virtual int init (); Virtual int run (); ; { return 0 for ThreadDerivedA::ThreadDerivedA (): ThreadBase () { } ThreadDerivedA: :~ThreadDerivedA () { } int ThreadDerivedA::init (); Int ThreadDerivedA::run () cout<<" ThreadDerivedA "<<endl; Return0; #endif
#ifndef_THREAD_DERIVEDB_H #define_THREAD_DERIVEDB_H #include " ThreadBase.h " #include<iostream.h〉using namespace std; //using std::cout; //using std::cin; //using std::endl; Class ThreadDerivedB:public ThreadBase/* creates derived class */{ public:ThreadDerivedB ();
~ThreadDerivedB(); virtual?int?init(); virtual?int?run();};ThreadDerivedB::ThreadDerivedB():ThreadBase(){}ThreadDerivedB::~ThreadDerivedB(){}int?ThreadDerivedB::init(){return?0;}int?ThreadDerivedB::run(){cout<<″ThreadDerivedB″<<endl;return0;}#endif
#ifndef_THREAD_APPLICATION_H #define_THREAD_APPLICATION_H #include″ThreadBase.h″ #include″ThreadDerivedA.h″ #include″ThreadDerivedB.h″ class?ThreadApplication { Bublic: ThreadApplication(); ~ThreadApplication(); void?startAll(); private: ThreadDerivedA?thA; ThreadDerivedB?thB; }; #endif
#include<unistd.h> #include″ThreadApplication.h″ ThreadApplication::ThreadApplication(){} ThreadApplication::~ThreadApplication(){}
VoidThreadApplication::startAll ()/* starts thread */{/* Start threadA and threadB with default attributes otherwise * run the thA.setThreadAttr () to set different thread attributes*/thA.startThread (); ThB.startThread (); Int main () { ThreadApplication mgr; Mgr.startAll (); Sleep (1); Return 0; }
Operation result:
Compile?the?files?by: g++-o?mthd../com/ThreadApplication.C-I../hdr/-lpthread-Wall Run?the?mthd?and?output?is?shown?blow: imfast>>./mthd ret=0 ret=0 ThreadDerivedA ThreadDerivedB imfast>>
Because derived class ThreadDerivedA and derived class ThreadDerivedB inherit in base class ThreadBase, so also do not redefine data member, member function startRoutine (void*arg) and the startThread () of base class therein.From the code of top multithreading startup method according to test sample of the present invention, can be clear that this point.
Fig. 1 shows according to the graph of a relation between each class of test sample of the present invention.Fig. 1 has also described the composition of each class briefly.
Thread called in proper order when Fig. 2 showed according to the startup multithreading of test sample of the present invention.
According to test sample of the present invention, in the time that thread being started, in the object of test class ThreadApplication, call the function startAll () of ThreadApplication.
StartAll () starts two thread startThread () by calling ThA.startThread () and ThB.startThread (), and the type of these two threads is respectively ThreadDerivedA and ThreadDerivedB.
The thread of the ThreadDerivedA that starts turns to entrance function startRoutine, and this function will call arg->run () execution thread task.Owing to use the parameter arg of this, and this thread is the thread of ThreadDerivedA, therefore will carries out the run () function of ThreadDerivedA as startRoutine.
The thread of the ThreadDerivedB that starts turns to entrance function startRoutine, and this function will call arg->run () execution thread task.Owing to use the parameter arg of this, and this thread is the thread of ThreadDerivedB, therefore will carries out the run () function of ThreadDerivedB as startRoutine.
In this example, user-defined class (being derived class) has been inherited the work of all startup threads of base class ThreadBase, and the class of itself only needs that run () is carried out heavy duty and gets final product.With the parameter of this as startRoutine (), and the member function that this startRoutine () is a base class, because the virtual function characteristic of run (), startRoutine () will determine the type of concrete object according to its parametric t his, thereby use corresponding run (), realize different tasks.
In addition, because the prototype definition requirement according to pthread_create () must have the function of an outside C type as its parameter s tart_routine (), and static function startRoutine () is the function of C++ class type, therefore need carry out forced type and transform.This can carry out in base class.
Following code in the code of above-mentioned multithreading startup method according to test sample of the present invention promptly is used to carry out the part of conversion in type:
#ifdef_cplusplus
extern“C”{
#endif
typedef?void*(*routineType)(void*);
#ifdef_cplusplus
}
#endif
As with the comparison of multithreading startup method according to the present invention, following code shows conventional multithreading startup method:
#ifndef_THREAD_A_H #define_THREAD_A_H #include<iostream.h> using?namespace?std; //using?std::cout; //using?std::cin; //using?std::endl; class?ThreadA { public: ThreadA(); ~ThreadA(); virtualint?init(); virtual?int?run(); inline?pthread_t*getTPtr(){return&threadId;} private: pthread_t?threadId; }; ThreadA::ThreadA():threadId(0) { } ThreadA::~ThreadA(){} int?ThreadA::init(){return?0;} int?ThreadA::run(){cout<<″ThreadA″<<endl;sleep(3);return?0;} #endif
#ifndef_THREAD_B_H #define_THREAD_B_H #include<iostream.h> using?namespace?std; //using?std::cout; //using?std::cin; //using?std::endl; class?ThreadB { public: ThreadB(); ~ThreadB(); virtualint?init(); virtualint?run(); inline?pthread_t*getTPtr(){return&threadId;} private: pthread_t?threadId; }; ThreadB::ThreadB():threadId(0) { } ThreadB::~ThreadB(){} int?ThreadB::init(){return?0;} int?ThreadB::run(){cout<<″ThreadB″<<endl;sleep(3);return?0;} #endif
#ifndef_THREAD_APPLICATION_H #define_THREAD_APPLICATION_H #include " ThreadA.h " #include " ThreadB.h " #ifdef_cplusplus/* forced type conversion */extern " C " { #endif
typedef?void*(*startRoutine)(void*); #ifdef_cplusplus } #endif class?ThreadApplication { public: ThreadApplication(); ~ThreadApplication(); static?void*spawnThA(ThreadA*thr); static?void*spawnThB(ThreadB*thr); int?startThA(ThreadA&thr); int?startThB(ThreadB&thr); void?startAll(); void?cancelAll();private: ThreadA?thA; ThreadB?thB;};#endif
#include<unistd.h> #include<pthread.h> #include″ThreadApplication.h″ ThreadApplication::ThreadApplication(){} ThreadApplication::~ThreadApplication(){} void* ThreadApplication::spawnThA(ThreadA*thr) { thr->run(); return?static_cast<void*>(thr); } int ThreadApplication::startThA(ThreadA&thr) { int?ret=-1; thr.init();
ret =pthread_create(thr.getTPtr(),NULL,reinterpret_cast<startRoutine>(spawnThA),(void*)&thr); cout<<″ret=″<<ret<<endl; return?ret;}void*ThreadApplication::spawnThB(ThreadB*thr){ thr->run(); return?static_cast<void*>(thr);}intThreadApplication::startThB(ThreadB&thr){ int?ret=-1; thr.init(); ret =pthread_create(thr.getTPtr(),NULL,reinterpret_cast<startRoHtine>(spawnThB),(void*)&thr); cout<<″ret=″<<ret<<endl; return?ret;}voidThreadApplication::startAll(){ startThA(thA); startThB(thB);}voidThreadApplication::cancelAll(){ if(*(thA.getTPtr())>0) { pthread_cancel(*(thA.getTPtr())); } if(*(thB.getTPtr())>0) { pthread_cancel(*(thB.getTPtr())); }
}int?main(){ ThreadApplication?mgr; mgr.startAll(); sleep(1); mgr.cancelAll(); return?0;}
From above-mentioned code as seen, in the multithreading startup method of routine, have following shortcoming: (1): all to define the operation function spawnThX () that a corresponding thread starts function startThX () and thread at each thread, this situation because their needs import that parameter is different to be caused into.(2): also require each thread class that an interface getTPtr () (using the privately owned member of the direct class of simple way to transmit its reference address in the example) who writes Thread Id (threadID) is provided.Therefore, by that analogy, how many different threads are arranged, just need above 3 functions are repeated to realize how many times.
Fig. 3 shows the process flow diagram according to the multithreading startup method of test sample of the present invention.
According to test sample of the present invention,, make up base class at step S301 place.
The common function (method) of a plurality of threads that definition will start in base class: write function getThreadId (), the thread startup function startThread of Thread Id and thread operation function startRoutine () and the correlation parameter that starts the entrance function of function as thread.Simultaneously, utilize the function of C++ to inherit and polymorphic characteristic, also defining virtual function in the thread operation function function of base class in the derived class of this base class virtual function is carried out heavy duty with convenient, thereby the different operation functions to each thread defines in derived class.
At step S303 place, according to each the function in a plurality of threads that will start, the virtual function of base class is carried out heavy duty, produce in a plurality of derived class of base class each.
At step S305 place, start thread, will come defining virtual CWinInetConnection type to quoting of derived class object as thread operation function parameters.Compiler can decide according to the type of virtual function carries out for which function.Thus,, can start a plurality of different threads, carry out different functions by different parameters.
In this test sample, there is not identical functions between a plurality of threads, therefore, startRoutine () only comprises virtual operation function run ().Certainly, the method according to a plurality of threads of startup of the embodiment of the invention can according to circumstances define different startRoutine ().For example, startRoutine () can comprise the common power function of described a plurality of thread.
As seen, multithreading startup method according to the present invention has realized following advantage:
1) work of Chong Fuing is placed in the base class and realizes, reduces the duplicated code amount;
2) interface is clear, is easy to safeguard;
3) with derived class quote or pointer as parameter, do not need to write extra code during programming because derived class is different, carry out the method for which derived class by compiler decision when the compiling.
Foregoing description and accompanying drawing only illustrate principle of the present invention.Therefore should be appreciated that those skilled in the art can advise different structures,, embodied principle of the present invention and be included within its spirit and scope though these different structures are not clearly described herein or illustrated.In addition, all examples of herein mentioning mainly only are used for teaching purpose clearly helping the design of reader understanding's principle of the present invention and promotion this area that the inventor was contributed, and should be interpreted as not being the restriction to these specific examples of mentioning and condition.In addition, all statement and specific examples thereof of mentioning principle of the present invention, aspect and embodiment comprise its equivalent interior herein.
Top description only is used to realize embodiments of the present invention; it should be appreciated by those skilled in the art; the any modification or partial replacement that is not departing from the scope of the present invention; all should belong to claim of the present invention and come restricted portion; therefore, protection scope of the present invention should be as the criterion with the protection domain of claims.

Claims (7)

1. multithreading startup method comprises step:
Create base class, described base class comprises the thread creation function and as the operation function of the entrance function of thread creation thread that function is created, described operation function comprises virtual function, a parameter-definition of described operation function the type of virtual function;
According to each the function in a plurality of threads that will start, the virtual function of base class is carried out heavy duty, produce in a plurality of derived class of base class each; And
By calling thread creation function in the base class, and will starting this thread to the quoting of derived class as described operation function parameters.
2. method according to claim 1, wherein, the operation function in the base class comprises the common function of a plurality of threads that will start.
3. method according to claim 1, wherein, described thread entrance function is converted to and meets the type that the thread creation function requires the thread entrance function type.
4. according to the described method of one of claim 1-3, wherein, described method is applied in the Object oriented programming environment.
5. method according to claim 4, wherein, described Object oriented programming environment is the C++ programmed environment.
6. method according to claim 5 wherein, is the address of derived class to quoting of derived class.
7. method according to claim 5, wherein, described thread creation function is pthread_create () function.
CN2010100015102A 2010-01-04 2010-01-04 Multi-thread starting method Pending CN102117222A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2010100015102A CN102117222A (en) 2010-01-04 2010-01-04 Multi-thread starting method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2010100015102A CN102117222A (en) 2010-01-04 2010-01-04 Multi-thread starting method

Publications (1)

Publication Number Publication Date
CN102117222A true CN102117222A (en) 2011-07-06

Family

ID=44216004

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2010100015102A Pending CN102117222A (en) 2010-01-04 2010-01-04 Multi-thread starting method

Country Status (1)

Country Link
CN (1) CN102117222A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105302557A (en) * 2015-10-30 2016-02-03 北京奇虎科技有限公司 Thread establishing and processing method and apparatus
CN105487852A (en) * 2015-11-11 2016-04-13 中国电子科技集团公司第四十一研究所 Policy mode based multi-thread management method for signal generator
WO2016061934A1 (en) * 2014-10-20 2016-04-28 中兴通讯股份有限公司 Qos configuration method and device, and computer storage medium
CN106383749A (en) * 2016-09-14 2017-02-08 郑州云海信息技术有限公司 Thread management method and apparatus
CN107577525A (en) * 2017-08-22 2018-01-12 努比亚技术有限公司 A kind of method, apparatus and computer-readable recording medium for creating concurrent thread
CN109918207A (en) * 2019-02-18 2019-06-21 天津麒麟信息技术有限公司 A kind of c program deadlock positioning method of non-intruding

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101482831A (en) * 2008-01-08 2009-07-15 国际商业机器公司 Method and equipment for concomitant scheduling of coexisting threading in multi-threading computer system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101482831A (en) * 2008-01-08 2009-07-15 国际商业机器公司 Method and equipment for concomitant scheduling of coexisting threading in multi-threading computer system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
胡忠: "Java多线程机制的研究与实践", 《达县师范高等专科学校学报(自然科学版)》 *
谈音: "DELPHI多线程机制剖析及其应用", 《电脑与信息技术》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016061934A1 (en) * 2014-10-20 2016-04-28 中兴通讯股份有限公司 Qos configuration method and device, and computer storage medium
CN105591766A (en) * 2014-10-20 2016-05-18 中兴通讯股份有限公司 Quality of service (QoS) configuration method and device
CN105302557A (en) * 2015-10-30 2016-02-03 北京奇虎科技有限公司 Thread establishing and processing method and apparatus
CN105487852A (en) * 2015-11-11 2016-04-13 中国电子科技集团公司第四十一研究所 Policy mode based multi-thread management method for signal generator
CN106383749A (en) * 2016-09-14 2017-02-08 郑州云海信息技术有限公司 Thread management method and apparatus
CN107577525A (en) * 2017-08-22 2018-01-12 努比亚技术有限公司 A kind of method, apparatus and computer-readable recording medium for creating concurrent thread
CN107577525B (en) * 2017-08-22 2020-11-17 努比亚技术有限公司 Method and device for creating concurrent threads and computer-readable storage medium
CN109918207A (en) * 2019-02-18 2019-06-21 天津麒麟信息技术有限公司 A kind of c program deadlock positioning method of non-intruding

Similar Documents

Publication Publication Date Title
Wimmer et al. Initialize once, start fast: application initialization at build time
Marlow et al. A monad for deterministic parallelism
Bull et al. JOMP—an OpenMP-like Interface for Java
Rompf et al. Building-blocks for performance oriented DSLs
Aldinucci et al. Behavioural skeletons in GCM: autonomic management of grid components
Bjørk et al. User-defined schedulers for real-time concurrent objects
CN102117222A (en) Multi-thread starting method
Demetrescu et al. Reactive imperative programming with dataflow constraints
Danelutto et al. P3ARSEC: Towards parallel patterns benchmarking
Bergmayr et al. fREX: fUML-based reverse engineering of executable behavior for software dynamic analysis
Cavé et al. Comparing the usability of library vs. language approaches to task parallelism
Goodman et al. Dfscala: High level dataflow support for scala
Miao et al. Compile-time reflection and metaprogramming for Java
Bosch et al. Characterizing and improving the performance of many-core task-based parallel programming runtimes
Sestoft et al. Technologies for evolvable software products: The conflict between customizations and evolution
Baum et al. Generic components to foster reuse
Demetrescu et al. Reactive imperative programming with dataflow constraints
Fors et al. Intercepting dataflow connections in diagrams with inheritance
Hinkel et al. Tool support for model transformations: on solutions using internal languages
Papoulias et al. Reifying the reflectogram
Papoulias et al. Reifying the reflectogram: Towards explicit control for implicit reflection
Hesse Dinosaur meets Archaeopteryx? Seven Theses on Rational's Unified Process (RUP)
Sewe et al. Redundancy-free residual dispatch: using ordered binary decision diagrams for efficient dispatch
Aldinucci et al. Adding metadata to Orc to support reasoning about grid programs
Doroshenko et al. Using Algebra-Algorithmic and Term Rewriting Tools for Developing Efficient Parallel Programs.

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
ASS Succession or assignment of patent right

Owner name: ALCATEL-LUCENT

Free format text: FORMER OWNER: ALCATEL-LUCENT AMERICA CO., LTD.

Effective date: 20120206

C41 Transfer of patent application or patent right or utility model
C53 Correction of patent of invention or patent application
CB02 Change of applicant information

Address after: New jersey, USA

Applicant after: ALCATEL-LUCENT USA Inc.

Address before: Box 636, Mount jasmine, 07974-0636, New Jersey, USA

Applicant before: Lucent Technologies Inc.

COR Change of bibliographic data

Free format text: CORRECT: APPLICANT; FROM: LUCENT TECHNOLOGIES INC. TO: ALCATEL-LUCENT AMERICA CO., LTD.

TA01 Transfer of patent application right

Effective date of registration: 20120206

Address after: Paris France

Applicant after: ALCATEL LUCENT

Address before: New jersey, USA

Applicant before: ALCATEL-LUCENT USA Inc.

C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20110706