CN106598745A - Thread management method and system - Google Patents

Thread management method and system Download PDF

Info

Publication number
CN106598745A
CN106598745A CN201611052681.1A CN201611052681A CN106598745A CN 106598745 A CN106598745 A CN 106598745A CN 201611052681 A CN201611052681 A CN 201611052681A CN 106598745 A CN106598745 A CN 106598745A
Authority
CN
China
Prior art keywords
file
asked
lock
thread
file lock
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
CN201611052681.1A
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.)
Hefei Branch Cloud Nest Technology Co Ltd
Original Assignee
Hefei Branch Cloud Nest Technology Co Ltd
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 Hefei Branch Cloud Nest Technology Co Ltd filed Critical Hefei Branch Cloud Nest Technology Co Ltd
Priority to CN201611052681.1A priority Critical patent/CN106598745A/en
Publication of CN106598745A publication Critical patent/CN106598745A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention provides a thread management method and system. The method comprises the following steps: judging whether a resident thread is already created or not before creating the resident thread according to an access request; and creating a corresponding resident thread only when a judgment result indicates that the resident thread is not created. Through adoption of the thread management method and system, creation of a plurality of resident threads specific to the same file can be effectively avoided, and waste of system resources is reduced.

Description

Thread management method and system
Technical field
The embodiment of the present invention relates to field of computer technology, more particularly to a kind of thread management method and system.
Background technology
(Python Web Server Gateway Interface, are abbreviated as Python Web server gateway interfaces WSGI) it is a kind of interface between Python application programs or framework and Web server, has been widely accepted, it is basic Reach the target in terms of its portability.In WSGI exploitations, serve end program can be divided into two parts, and one is server journey Sequence, two is application program.The former is responsible for client request to receive, arranges, and the latter is responsible for specific logical process.Using WSGI Characteristic, can generate a resident thread, asynchronous process business when server program is initialized.
During the present invention is realized, the inventors found that:Because WSGI is developed based on web server, web Server may create multi-process when request is processed, and multithreading causes resident thread repeatedly to create.Can so waste and be System resource.
The content of the invention
One purpose of the embodiment of the present invention is to provide a kind of thread management method and system, to avoid resident thread Repeatedly created.
To reach above-mentioned purpose, the embodiment of one aspect of the invention provides a kind of thread management method, including:
When the access request of the resident thread of request establishment is received, judge whether to have been for what the access request was asked The resident thread of document creation;The access request is used to access the web services of WSGI;
Only when judging not creating resident thread, corresponding resident thread is created.
The embodiment of another aspect of the invention provides a kind of thread management system, including:
Judge module, for when the access request of the resident thread of request establishment is received, judging whether to have been for the visit Ask the asked document creation of request resident thread;The access request is used to access the web services of WSGI;
Thread creation module, when judging not creating resident thread, corresponding resident thread is created for only.
Thread management method provided in an embodiment of the present invention and system, before resident thread is created according to access request, Judge whether to have created resident thread, and only create corresponding resident thread when judging not creating resident thread.So Can just be prevented effectively from and create multiple resident threads for same file, reduce the waste of system resource.
Description of the drawings
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, embodiment will be described below Needed for the accompanying drawing to be used be briefly described, it should be apparent that, drawings in the following description be only the present invention some Example, for those of ordinary skill in the art, on the premise of not paying creative work, can be with according to these accompanying drawings Obtain other accompanying drawings.
Fig. 1 is the schematic flow sheet of thread management method provided in an embodiment of the present invention;
Fig. 2 is the structural representation of the thread management system that inventive embodiments are provided.
Specific embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete Site preparation is described, it is clear that described embodiment is only a part of embodiment of the invention, rather than the embodiment of whole.It is based on Embodiment in the present invention, the every other reality that ordinary skill people is obtained under the premise of creative work is not made Example is applied, the scope of protection of the invention is belonged to.
A kind of thread management method is embodiments provided, referring to Fig. 1, the method includes:
Step S1, when the access request of the resident thread of request establishment is received, judges whether to have been for the access request The resident thread of the document creation asked;The access request is used to access the web services of WSGI;
Step S2, only when judging not creating resident thread, creates corresponding resident thread.
In certain embodiments, methods described also includes:It is that asked file is opened when corresponding resident thread is created Open file lock;
It is described to judge whether to have been for the resident thread of the document creation that the access request is asked, including:
Judge whether to have been for the file opening that the access request is asked file lock, when file lock is opened, sentence It is disconnected to have been for the resident thread of the document creation that the access request is asked.
In this way, can be fairly simple judge whether has been for the document creation that the access request is asked Resident thread.
In certain embodiments, the file setting file lock to be asked can include:
The attribute of the file asked in by changing fcntl function libraries is that the attribute of asked file arranges file Lock.Thus taking full advantage of fcntl function libraries can change the function of opened file property, and before thread starts one is created The file lock of individual mutual exclusion, when again thread is opened in request, checks file lock whether lock-out state, if locking proves had Thread, does not allow to open.It is achieved in that more simple.
In certain embodiments, before for the file opening file lock asked, methods described also includes:
Judge whether that having been for asked file is provided with file lock;
The file opening file lock to be asked, including:
It is asked file opening file lock when file lock is provided with for asked file;For asking It is that asked file arranges file lock and file opening lock when the file asked does not have file lock.
In certain embodiments, the file to be asked is arranged before file lock, and methods described also includes:
The file lock of detection user input arranges instruction, and the file lock arranges instruction to be needed to arrange file lock for instruction File;
The file to be asked arranges file lock, including:
It is that asked file arranges file lock when indicated file includes asked file.
In this way, can allow for user and the function that above-mentioned file lock is performed for those files is set, can More flexibly meet being actually needed for user.
Second aspect, the embodiment of the present invention additionally provides a kind of thread management system, referring to Fig. 2, including:
Judge module 21, for when the access request of the resident thread of request establishment is received, judging whether to have been for this The resident thread of the document creation that access request is asked;The access request is used to access the web services of WSGI;
Thread creation module 22, when judging not creating resident thread, corresponding resident thread is created for only.
In certain embodiments, thread creation module 22 can be also used for when corresponding resident thread is created, to be asked The file opening file lock asked;
Now, judge module 21 can be also used for, and judge whether to have been for the document creation that the access request is asked Resident thread, including:
Judge whether to have been for the file opening that the access request is asked file lock, when file lock is opened, sentence It is disconnected to have been for the resident thread of the document creation that the access request is asked.
In certain embodiments, thread creation module 22 is used for the setting of the file to be asked file lock includes:
The attribute of the file asked in by changing fcntl function libraries is that the attribute of asked file arranges file Lock.
In certain embodiments, thread creation module 22 was additionally operable to before for the file opening file lock asked, and was sentenced It is disconnected whether to have been for asked file and be provided with file lock;
Thread creation module 22 is used for the file to be asked and arranges file lock and the file opening file lock to be asked Process, including:
It is asked file opening file lock when file lock is provided with for asked file;For asking It is that asked file arranges file lock and file opening lock when the file asked does not have file lock.
In certain embodiments, above-mentioned system can also include:
Instruction detection module, for before thread creation module is asked file setting file lock, detecting user The file lock of input arranges instruction, and the file lock arranges instruction for the file for indicating to need to arrange file lock;
The thread creation module 22 arranges file lock for the file asked, including:
It is that asked file arranges file lock when indicated file includes asked file.
In description mentioned herein, a large amount of details are illustrated.It is to be appreciated, however, that the enforcement of the present invention Example can be put into practice in the case of without these details.In some instances, known method, structure is not been shown in detail And technology, so as not to obscure the understanding of this description.
Similarly, it will be appreciated that in order to simplify the disclosure and help understand one or more in each inventive aspect, exist Above in the description of the exemplary embodiment of the present invention, each feature of the present invention is grouped together into single enforcement sometimes In example, figure or descriptions thereof.However, the method for the disclosure should be construed to reflect following intention:I.e. required guarantor The more features of feature that the application claims ratio of shield is expressly recited in each claim.More precisely, such as following Claims reflect as, inventive aspect is all features less than single embodiment disclosed above.Therefore, Thus the claims for following specific embodiment are expressly incorporated in the specific embodiment, wherein each claim itself All as the separate embodiments of the present invention.
Those skilled in the art are appreciated that can be carried out adaptively to the module in the equipment in embodiment Change and they are arranged in one or more equipment different from the embodiment.Can be the module or list in embodiment Unit or component are combined into a module or unit or component, and can be divided in addition multiple submodule or subelement or Sub-component.In addition at least some in such feature and/or process or unit is excluded each other, can adopt any Combine to all features disclosed in this specification (including adjoint claim, summary and accompanying drawing) and so disclosed Where all processes or unit of method or equipment are combined.Unless expressly stated otherwise, this specification is (including adjoint power Profit is required, summary and accompanying drawing) disclosed in each feature can it is identical by offers, be equal to or the alternative features of similar purpose carry out generation Replace.
Although additionally, it will be appreciated by those of skill in the art that some embodiments in this include institute in other embodiments Including some features rather than further feature, but the combination of the feature of different embodiment means in the scope of the present invention Within and form different embodiments.For example, in the following claims, embodiment required for protection it is any it One can in any combination mode using.
The present invention some unit embodiments can be realized with hardware, or with one or more processor operation Software module realize, or with combinations thereof realization.It will be understood by those of skill in the art that can use in practice Microprocessor to realize gateway according to embodiments of the present invention, proxy server, system in some or all parts one A little or repertoire.The present invention is also implemented as being set for performing some or all of method as described herein Standby or program of device (for example, computer program and computer program).Such program for realizing the present invention can be deposited Storage on a computer-readable medium, or can have the form of one or more signal.Such signal can be from because of spy Download on net website and obtain, or provide on carrier signal, or provide in any other form.
It should be noted that above-described embodiment the present invention will be described rather than limits the invention, and ability Field technique personnel can design without departing from the scope of the appended claims alternative embodiment.In the claims, Any reference markss between bracket should not be configured to limitations on claims.Word "comprising" is not excluded the presence of not Element listed in the claims or step.Word "a" or "an" before element does not exclude the presence of multiple such Element.The present invention can come real by means of the hardware for including some different elements and by means of properly programmed computer It is existing.If in the unit claim for listing equipment for drying, several in these devices can be by same hardware branch To embody.The use of word first, second, and third does not indicate that any order.These words can be explained and be run after fame Claim.

Claims (10)

1. a kind of thread management method, it is characterised in that include:
When the access request of the resident thread of request establishment is received, judge whether to have been for the file that the access request is asked Create resident thread;The access request is used to access the web services of WSGI;
Only when judging not creating resident thread, corresponding resident thread is created.
2. method according to claim 1, it is characterised in that methods described also includes:Creating corresponding resident thread When, it is asked file opening file lock;
It is described to judge whether to have been for the resident thread of the document creation that the access request is asked, including:
Judge whether to have been for the file opening that the access request is asked file lock, when file lock is opened, judge The resident thread of the document creation asked for the access request.
3. method according to claim 2, it is characterised in that described file lock is set for the file asked to include:
The attribute of the file asked in by changing fcntl function libraries is that the attribute of asked file arranges file lock.
4. method according to claim 2, it is characterised in that described before for the file opening file lock asked Method also includes:
Judge whether that having been for asked file is provided with file lock;
The file opening file lock to be asked, including:
It is asked file opening file lock when file lock is provided with for asked file;It is being directed to what is asked It is that asked file arranges file lock and file opening lock when file does not have file lock.
5. method according to claim 4, it is characterised in that the file to be asked is arranged before file lock, institute Stating method also includes:
The file lock of detection user input arranges instruction, and the file lock arranges instruction for the text for indicating to need to arrange file lock Part;
The file to be asked arranges file lock, including:
It is that asked file arranges file lock when indicated file includes asked file.
6. a kind of thread management system, it is characterised in that include:
Judge module, for when the access request of the resident thread of request establishment is received, judging whether that having been for the access asks Seek the resident thread of asked document creation;The access request is used to access the web services of WSGI;
Thread creation module, when judging not creating resident thread, corresponding resident thread is created for only.
7. system according to claim 6, it is characterised in that
Thread creation module is additionally operable to when corresponding resident thread is created, and is asked file opening file lock;
The judge module is used for, and judges whether to have been for the resident thread of the document creation that the access request is asked, including:
Judge whether to have been for the file opening that the access request is asked file lock, when file lock is opened, judge The resident thread of the document creation asked for the access request.
8. system according to claim 7, it is characterised in that the thread creation module is used for the file to be asked and sets Putting file lock includes:
The attribute of the file asked in by changing fcntl function libraries is that the attribute of asked file arranges file lock.
9. system according to claim 7, it is characterised in that the thread creation module is additionally operable in the text to be asked Before part file opening lock, judge whether that having been for asked file is provided with file lock;
The thread creation module is used for the setting file lock of the file to be asked and for the file opening file lock asked Process, including:
It is asked file opening file lock when file lock is provided with for asked file;It is being directed to what is asked It is that asked file arranges file lock and file opening lock when file does not have file lock.
10. system according to claim 8, it is characterised in that also include:
Instruction detection module, for before thread creation module is asked file setting file lock, detecting user input File lock instruction is set, the file lock arranges instruction for the file for indicating to need to arrange file lock;
The thread creation module is that asked file arranges file lock, including:
It is that asked file arranges file lock when indicated file includes asked file.
CN201611052681.1A 2016-11-24 2016-11-24 Thread management method and system Pending CN106598745A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611052681.1A CN106598745A (en) 2016-11-24 2016-11-24 Thread management method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611052681.1A CN106598745A (en) 2016-11-24 2016-11-24 Thread management method and system

Publications (1)

Publication Number Publication Date
CN106598745A true CN106598745A (en) 2017-04-26

Family

ID=58593319

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611052681.1A Pending CN106598745A (en) 2016-11-24 2016-11-24 Thread management method and system

Country Status (1)

Country Link
CN (1) CN106598745A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108280113A (en) * 2017-07-13 2018-07-13 广州市动景计算机科技有限公司 Service Worker control methods, device and electric terminal
CN109388485A (en) * 2018-09-26 2019-02-26 广州虎牙信息科技有限公司 A kind of processing method, device, equipment and the storage medium of task execution thread

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7827559B1 (en) * 2006-04-24 2010-11-02 Real-Time Innovations, Inc. Framework for executing multiple threads and sharing resources in a multithreaded computer programming environment
CN102262559A (en) * 2010-05-24 2011-11-30 腾讯科技(深圳)有限公司 Resource sharing method and system
CN105912386A (en) * 2016-05-03 2016-08-31 深圳市永兴元科技有限公司 Thread management method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7827559B1 (en) * 2006-04-24 2010-11-02 Real-Time Innovations, Inc. Framework for executing multiple threads and sharing resources in a multithreaded computer programming environment
CN102262559A (en) * 2010-05-24 2011-11-30 腾讯科技(深圳)有限公司 Resource sharing method and system
CN105912386A (en) * 2016-05-03 2016-08-31 深圳市永兴元科技有限公司 Thread management method and system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108280113A (en) * 2017-07-13 2018-07-13 广州市动景计算机科技有限公司 Service Worker control methods, device and electric terminal
CN108280113B (en) * 2017-07-13 2021-04-30 阿里巴巴(中国)有限公司 Service Worker control method and device and electronic terminal
CN109388485A (en) * 2018-09-26 2019-02-26 广州虎牙信息科技有限公司 A kind of processing method, device, equipment and the storage medium of task execution thread

Similar Documents

Publication Publication Date Title
RU2419854C2 (en) Template based service management
US9727439B2 (en) Tracking application deployment errors via cloud logs
AU2015267387B2 (en) Method and apparatus for automating the building of threat models for the public cloud
US8301653B2 (en) System and method for capturing and reporting online sessions
US8694886B2 (en) Providing dynamic context assist for a command line interface
US10491621B2 (en) Website security tracking across a network
US11095648B2 (en) Dashboard as remote computing services
US20060195816A1 (en) Methods and systems for implementing on-line financial institution services via a single platform
US7860956B2 (en) Transferring selected open browser tabs from a host computer to a client computer
CN111868727B (en) Method and system for data anonymization
DE202014010889U1 (en) Priority static hosted web applications
US20170364844A1 (en) Automated-application-release-management subsystem that supports insertion of advice-based crosscutting functionality into pipelines
CA2717505C (en) Method and apparatus for dynamic provisioning in data processing environment
Colesky et al. A system of privacy patterns for informing users: Creating a pattern system
US8621550B1 (en) Information technology resource compliance templates
US10678933B2 (en) Security systems GUI application framework
CN110633120A (en) Configuration software control processing method, device, server, user terminal and system
JP6276709B2 (en) Context-sensitive application interaction
JP2009527832A (en) Virtual role
US8161456B2 (en) Management of heterogeneous software artifacts through a common representation
CN106598745A (en) Thread management method and system
CN108289080B (en) Method, device and system for accessing file system
US20120159611A1 (en) Central Administration and Abstraction of Licensed Software Features
Goldsteen et al. Application-screen masking: a hybrid approach
US20090055738A1 (en) Techniques for Providing Dynamic Help Content for a Command Line Interface

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20170426