CN102841803A - Method and device for asynchronously calling local codes in java thread - Google Patents

Method and device for asynchronously calling local codes in java thread Download PDF

Info

Publication number
CN102841803A
CN102841803A CN2011101738048A CN201110173804A CN102841803A CN 102841803 A CN102841803 A CN 102841803A CN 2011101738048 A CN2011101738048 A CN 2011101738048A CN 201110173804 A CN201110173804 A CN 201110173804A CN 102841803 A CN102841803 A CN 102841803A
Authority
CN
China
Prior art keywords
thread
java
java thread
message
local
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
CN2011101738048A
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.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN2011101738048A priority Critical patent/CN102841803A/en
Publication of CN102841803A publication Critical patent/CN102841803A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention relates to a method for asynchronously calling local codes in a java thread. The method is applied to asynchronously calling local codes in the java thread by local codes of a local thread, and comprises the steps of distributing a part number (Pno) for the java thread; starting the java thread through a java thread starting interface in a local control module when an application is started; registering the java thread to a page control block (PCB) data region; transmitting a calling message to a message queue of the java thread by the local thread, and completing the calling of the corresponding function by the local codes in the java thread according to the calling message. The invention provides another method for calling the local codes in the java thread, wherein the method is applied to calling the local codes in the java thread by the local codes of the java thread. The invention also provides a device for calling the local codes in the java thread. By using the technical scheme of the invention, development cycles are reduced, costs are saved, and versions can be extended and maintained conveniently.

Description

The method and the device of local code in a kind of asynchronous call java thread
Technical field
The present invention relates to the mobile Internet field, the method and the device of local code in particularly a kind of asynchronous call java thread.
Background technology
Along with the continuous development of mobile Internet, intelligent movable operating system presents variation, and portable terminal is used and emerged in an endless stream.New intelligent Mobile operating system android has caused huge repercussion in the whole world, a large amount of software developers drops into wherein.Android mobile system application layer software is main with the java language development; But also allow the developer to use other Languages (c/c++); This has brought Gospel to the developer who is familiar with c/c++, can also be transplanted to ready-made c/c++ local code in the android system simultaneously.But some api of c/c++ local code can't use in the android system, for example: and message queue, shared drive etc., in addition, all compare difficulty for the track and localization of c thread.How to utilize upper strata java to combine c/c++ to realize that system development has become the very urgent problem that will consider.
Summary of the invention
The technical matters that the present invention solves has been to provide the method for local code in a kind of asynchronous call java thread, and message queue, Sharing Memory Realization local code asynchronous call can't be used in the c storehouse that overcomes android, and make things convenient for track thread state etc.; The present invention also provides the device of local code in a kind of asynchronous call java thread.
For addressing the above problem, the invention provides the method for local code in a kind of asynchronous call java thread, comprise,
For the java thread distributes thread number Pno;
When application start, start the java thread through starting java thread interface in the Local Control Module;
Said Java thread is registered to process control block (PCB) PCB data field;
Said local thread sends the message queue of message call to java thread, and local code is accomplished calling of respective function according to said message call in the said java thread.
Simultaneously, the invention provides the method for local code in other a kind of asynchronous call java thread, comprise,
For the java thread distributes thread number Pno;
When application start, start the java thread through starting java thread interface in the Local Control Module;
Said Java thread is registered to process control block (PCB) PCB data field;
A java thread sends the message queue of message call to another java thread, and local code is accomplished calling of respective function according to said message call in the said java thread.
The present invention also provides the device of local code in a kind of asynchronous call java thread, comprises,
The thread number distribution module is used to the java thread and distributes thread number Pno;
Local Control Module is used for when application start, starts the java thread through starting java thread interface;
The thread Registering modules is used for the Java thread and registers to process control block (PCB) PCB data field;
The asynchronous call module is used for when the message queue of a said local thread or java thread transmission message call to a java thread, and local code is accomplished calling of respective function according to said message call in the said java thread.
Adopt technical scheme of the present invention; Message queue, Sharing Memory Realization local code asynchronous call can't be used in the c storehouse that overcomes android; And make things convenient for track thread state etc.; Utilized not only that technology has reduced the construction cycle in the android system, practiced thrift cost, and made things convenient for the expansion of version to safeguard.
Description of drawings
Accompanying drawing described herein is used to provide further understanding of the present invention, constitutes a part of the present invention, and illustrative examples of the present invention and explanation thereof are used to explain the present invention, does not constitute improper qualification of the present invention.In the accompanying drawings:
Fig. 1 is the present invention's first method embodiment process flow diagram;
Fig. 2 is the present invention's second method embodiment process flow diagram;
Fig. 3 is the third embodiment of the invention system construction drawing.
Embodiment
In order to make technical matters to be solved by this invention, technical scheme and beneficial effect clearer, clear,, the present invention is further elaborated below in conjunction with accompanying drawing and embodiment.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
As shown in Figure 1, be the present invention's first method embodiment process flow diagram, provide a kind of local code of local thread to call the method for the local code in the java thread, may further comprise the steps:
Step S101 is for the java thread distributes thread number pno, message distribution when being convenient to asynchronous call;
Step S102 during application start, starts the java thread through the startJavaThread in the Local Control Module (starting the java thread) interface;
Step S103, the java thread is registered to PCB (process control block (PCB)) data field;
Step S104; Create local thread; Send message call to the message queue that distributes in pno number the java thread through postMessageEX (int recieverpno, int msgPtr), local code is accomplished calling of respective function according to the value of msgPtr data structure in the java thread;
Particularly; After the java thread started and is accomplished to the registration of pcb data field, local thread was through calling postMessageEX (int recieverpno, int msgPtr); The recieverpno corresponding thread number of local code that refers to be called wherein, msgPtr refers to the data structure parameter transmitted; PostMessageEX need append to local thread in the java virtual machine before the java thread sends message queue, and only in this way local thread just can call the java call back function; When java is called; Traversal thread hash table finds the message handle of corresponding thread; And send in the message queue of java thread through this message handle; The message queue processing function of java thread takes out message from message queue after; The local function call pointer lpentry that calls in the PCB data field of java registration gets into local code, the function that local code is corresponding according to the data structure parameter call among the msgPtr, and wherein lpentry Unified Treatment asynchronous call is accomplished message distribution simultaneously in concrete function.
As shown in Figure 2, be the present invention's second method embodiment process flow diagram, provide local code in a kind of java thread to call the method for local code in the java thread, may further comprise the steps:
Step S201 is that two java threads distribute message distribution when being convenient to asynchronous call pno number;
Step S202 during application start, starts said two java threads through the startJavaThread interface in the Local Control Module;
Step S203, said two threads are registered to the pcb data field;
Step S204; One of them java thread can pass through postMessag (int recieverpno; IntmsgPtr) method is sent message call message queue in another thread, and local code is accomplished calling of respective function according to the value of msgPtr data structure in the java thread.
Particularly; After two java threads start and are accomplished to the registration of pcb data field; One of them java thread is through calling postMessage (int recieverpno; Int msgPtr), the recieverpno corresponding thread number of local code that refers to be called wherein, msgPtr refers to the data structure parameter transmitted; When java is called; Find the message handle of corresponding thread through traversal thread hash table; Send in the message queue of thread through this message handle; After the message queue of java thread was handled function and from formation, taken out message, the local function call pointer lpentry that calls in the PCB data field of java registration got into local code, and local code is according to the function of the correspondence of the data structure parameter call among the msgPtr.
As shown in Figure 3, be the third embodiment of the invention system construction drawing, the device of local code in a kind of asynchronous call java thread is provided, comprise,
Thread number distribution module 301 is used to the java thread and distributes thread number Pno;
Local Control Module 302 is used for when application start, starts the java thread through starting java thread interface;
Thread Registering modules 303 is used for the Java thread and registers to process control block (PCB) PCB data field;
Asynchronous call module 304 is used for when the message queue of a said local thread or java thread transmission message call to a java thread, and local code is accomplished calling of respective function according to said message call in the said java thread.
Said message call comprises be called the java thread number of local code correspondence and the data structure parameter of transmission.
Said asynchronous call module is used for said java thread local code and is specially according to said calling of respective function of message call completion,
When said local thread sends the message queue of message call to java thread; The java thread is called; Traversal thread hash table finds the message handle of corresponding java thread; And send the corresponding java thread number of the local code that is called in the message queue of java thread through this message handle; After the message queue of java thread was handled function and from message queue, taken out corresponding java thread, the local function call pointer lpentry that calls in the PCB data field of java thread registration got into local code, and said local code is according to the function of the data structure parameter call correspondence of transmitting; Perhaps
When a said java thread sends the message queue of message call to java thread; The java thread is called; Find the message handle of corresponding thread through traversal thread hash table; Send the corresponding java thread number of the local code that is called in the message queue of thread through this message handle; After the message queue of java thread was handled function and from formation, taken out corresponding java thread, the local function call pointer lpentry that calls in the PCB data field of java registration got into local code, and local code is according to the function of the data structure parameter call correspondence of transmitting.
Local Control Module; Also be used to encapsulate control method primitive; Be convenient to transparent calling between the local code; Definition thread module PCB (process control block (PCB)) data field; This data field comprises thread sign id, thread id, thread title, thread entrance function pointer etc., and cross-thread message indicates id through thread and distinguishes, and encapsulates the adaptable interface postMessage, postMessageEx, startJavaThread, stopJavaThread on local interface and java upper strata etc. in addition; The postMessage function is mainly accomplished the asynchronous transmission of message of java cross-thread, and the postMessageEx function is mainly accomplished the message transmission of local c thread and java cross-thread and only supported the unidirectional delivery of c thread to the java thread;
Said asynchronous call module also is used to safeguard android message handle and message queue and adaptive with local interface.
Above-mentioned explanation illustrates and has described a preferred embodiment of the present invention; But as previously mentioned; Be to be understood that the present invention is not limited to the form that this paper discloses, should do not regard eliminating as, and can be used for various other combinations, modification and environment other embodiment; And can in invention contemplated scope described herein, change through the technology or the knowledge of above-mentioned instruction or association area.And change that those skilled in the art carried out and variation do not break away from the spirit and scope of the present invention, then all should be in the protection domain of accompanying claims of the present invention.

Claims (10)

1. the method for local code in the asynchronous call java thread is characterized in that, comprise,
For the java thread distributes thread number Pno;
When application start, start the java thread through starting java thread interface in the Local Control Module;
Said java thread is registered to process control block (PCB) PCB data field;
Said local thread sends the message queue of message call to java thread, and local code is accomplished calling of respective function according to said message call in the said java thread.
2. method according to claim 1 is characterized in that, said message call comprises be called the java thread number of local code correspondence and the data structure parameter of transmission.
3. method according to claim 2 is characterized in that, local code is specially according to said calling of respective function of message call completion in the said java thread,
When the java thread is called; Traversal thread hash table finds the message handle of corresponding java thread; And send the corresponding java thread number of the local code that is called in the message queue of java thread through this message handle; The message queue processing function of java thread takes out corresponding java thread from message queue after; The local function call pointer that calls in the PCB data field of java thread registration gets into local code, the function that said local code is corresponding according to the data structure parameter call of transmitting.
4. according to the arbitrary described method of claim 1 to 3; It is characterized in that; In the said method, through the message transport function before java thread message queue sends message call, said local thread being appended in the java virtual machine, so that local thread calls the java call back function.
5. the method for local code in the asynchronous call java thread is characterized in that, comprise,
For the java thread distributes thread number Pno;
When application start, start the java thread through starting java thread interface in the Local Control Module;
Said Java thread is registered to process control block (PCB) PCB data field;
A java thread sends the message queue of message call to another java thread, and local code is accomplished calling of respective function according to said message call in the said java thread.
6. method according to claim 5 is characterized in that, said message call comprises be called the java thread number of local code correspondence and the data structure parameter of transmission.
7. method according to claim 6 is characterized in that, local code is specially according to said calling of respective function of message call completion in the said java thread,
When the java thread is called; Find the message handle of corresponding thread through traversal thread hash table; Send the corresponding java thread number of the local code that is called in the message queue of thread through this message handle; After the message queue of java thread was handled function and from formation, taken out corresponding java thread, the local function call pointer that calls in the PCB data field of java registration got into local code, and local code is according to the function of the data structure parameter call correspondence of transmitting.
8. the device of local code in the asynchronous call java thread is characterized in that, comprise,
The thread number distribution module is used to the java thread and distributes thread number Pno;
Local Control Module is used for when application start, starts the java thread through starting java thread interface;
The thread Registering modules is used for the Java thread and registers to process control block (PCB) PCB data field;
The asynchronous call module is used for when the message queue of a said local thread or java thread transmission message call to a java thread, and local code is accomplished calling of respective function according to said message call in the said java thread.
9. device according to claim 8 is characterized in that, said message call comprises be called the java thread number of local code correspondence and the data structure parameter of transmission.
10. device according to claim 9 is characterized in that, said asynchronous call module is used for said java thread local code and is specially according to said calling of respective function of message call completion,
When said local thread sends the message queue of message call to java thread; The java thread is called; Traversal thread hash table finds the message handle of corresponding java thread; And send the corresponding java thread number of the local code that is called in the message queue of java thread through this message handle; After the message queue of java thread was handled function and from message queue, taken out corresponding java thread, the local function call pointer that calls in the PCB data field of java thread registration got into local code, and said local code is according to the function of the data structure parameter call correspondence of transmitting; Perhaps
When a said java thread sends the message queue of message call to java thread; The java thread is called; Find the message handle of corresponding thread through traversal thread hash table; Send the corresponding java thread number of the local code that is called in the message queue of thread through this message handle; After the message queue of java thread was handled function and from formation, taken out corresponding java thread, the local function call pointer that calls in the PCB data field of java registration got into local code, and local code is according to the function of the data structure parameter call correspondence of transmitting.
CN2011101738048A 2011-06-24 2011-06-24 Method and device for asynchronously calling local codes in java thread Pending CN102841803A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2011101738048A CN102841803A (en) 2011-06-24 2011-06-24 Method and device for asynchronously calling local codes in java thread

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2011101738048A CN102841803A (en) 2011-06-24 2011-06-24 Method and device for asynchronously calling local codes in java thread

Publications (1)

Publication Number Publication Date
CN102841803A true CN102841803A (en) 2012-12-26

Family

ID=47369203

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2011101738048A Pending CN102841803A (en) 2011-06-24 2011-06-24 Method and device for asynchronously calling local codes in java thread

Country Status (1)

Country Link
CN (1) CN102841803A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106371900A (en) * 2015-07-23 2017-02-01 腾讯科技(深圳)有限公司 Data processing method and device for realizing asynchronous call
CN106708614A (en) * 2016-11-21 2017-05-24 桂林远望智能通信科技有限公司 Multi-thread creation system and method, and multi-thread processing system and method
CN108399120A (en) * 2017-02-06 2018-08-14 腾讯科技(深圳)有限公司 asynchronous message monitoring method and device
CN108874523A (en) * 2018-06-21 2018-11-23 深圳点猫科技有限公司 A kind of programmed method based on the AI and promise of children education control asynchronous function sequence
CN108958903A (en) * 2017-05-25 2018-12-07 北京忆恒创源科技有限公司 Embedded multi-core central processing unit method for scheduling task and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
若水的博客: "深入剖析Android消息机制", 《HTTP://BLOG.CSDN.NET/COOLSZY/ARTICLE/DETAILS/6360577》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106371900A (en) * 2015-07-23 2017-02-01 腾讯科技(深圳)有限公司 Data processing method and device for realizing asynchronous call
CN106371900B (en) * 2015-07-23 2020-06-05 腾讯科技(深圳)有限公司 Data processing method and device for realizing asynchronous call
CN106708614A (en) * 2016-11-21 2017-05-24 桂林远望智能通信科技有限公司 Multi-thread creation system and method, and multi-thread processing system and method
CN106708614B (en) * 2016-11-21 2019-12-10 桂林远望智能通信科技有限公司 multithreading creating system and method and multithreading processing system and method
CN108399120A (en) * 2017-02-06 2018-08-14 腾讯科技(深圳)有限公司 asynchronous message monitoring method and device
CN108958903A (en) * 2017-05-25 2018-12-07 北京忆恒创源科技有限公司 Embedded multi-core central processing unit method for scheduling task and device
CN108958903B (en) * 2017-05-25 2024-04-05 北京忆恒创源科技股份有限公司 Embedded multi-core central processor task scheduling method and device
CN108874523A (en) * 2018-06-21 2018-11-23 深圳点猫科技有限公司 A kind of programmed method based on the AI and promise of children education control asynchronous function sequence

Similar Documents

Publication Publication Date Title
CN102841803A (en) Method and device for asynchronously calling local codes in java thread
CN102591726B (en) Multiprocess communication method
CN102843393B (en) Running device and method of network application
CN112671760A (en) Socket-based client cross-platform network communication method and related equipment thereof
CN105242962A (en) Quick lightweight thread triggering method based on heterogeneous many-core
CN103049320A (en) Method and device for starting external application program in browser
CN105446755A (en) Method and device for rapidly loading Activity data for Android system
KR20190005152A (en) Mobile terminal application update method and apparatus
CN107682206A (en) The dispositions method and system of business process management system based on micro services
CN105786839A (en) Application data acquisition method and apparatus
CN105743955A (en) Method for JavaScript object expansion
CN111158690A (en) Desktop application framework, construction method, desktop application running method and storage medium
CN104035768B (en) The system and method for Android platform compatibility local code OpenGL programs
CN107483412A (en) A kind of HTML5 web worker moving methods and system
CN104866335A (en) Egret-Runtime-based game running method and device for mobile terminal
CN104636249A (en) Generation system and method of debugging information of application program
CN102685153A (en) Method for opening third-party service by resource platform and resource platform
CN103677824A (en) OTT terminal solution based on customized browser
CN109542829A (en) The control method of GPU equipment, device and electronic equipment in multisystem
CN102891854A (en) Cloud server safety control method
CN112925586A (en) Applet routing method, device, computer equipment and storage medium
CN109857374B (en) Development method and device of mobile application
CN103870280A (en) Webpage seamless combining processing method based on FLEX and JSP
CN102609299A (en) Virtualizing system, and creating method and creating device thereof
CN103077016B (en) A kind of moving object creation method, device and browser

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20121226