System and method for handling threads of execution
First Claim
1. A system, comprising:
- a dedicated Java thread handler class which includes;
a start method that sets a target variable to indicate that a thread extending said dedicated Java thread handler class is running;
an abstract run method; and
a stop method that sets said target variable to indicate that said thread extending said Java class is to be stopped;
wherein said dedicated Java thread handler class is configured to be extended by custom thread subclasses that each includes a run method that overrides said abstract run method of said Java class, wherein said dedicated Java thread handler class does not include functionality particular to any of the custom thread subclasses, wherein said run method of one of the custom thread subclasses;
provides one or more instructions to be executed within said thread, wherein said instructions are configured to access one or more objects during execution of said thread;
provides one or more checks during execution of said thread to determine if said target variable indicates that said thread is to be stopped; and
completes execution of said run method if one of the one or more checks determines that said thread is to be stopped;
wherein completing execution of said run method if one of the one or more checks determines that said thread is to be stopped stops the thread without throwing an exception and leaves each of said one or more objects in a consistent state.
1 Assignment
0 Petitions
Accused Products
Abstract
A mechanism for controlling threads in a Java application while avoiding the unsafe conditions inherent in the use of existing java.lang.Thread methods. In one embodiment, a first class is defined for handling threads in an application. The first class uses a target variable to indicate whether a thread should continue to run, or whether it should be stopped. This first class provides a start( ) method to set up the target variable, a stop( ) method to set the target variable to indicate that the thread should be stopped, and an abstract run( ) method. The functionality of the run( ) method is provided by one or more additional classes which extend the first class. The additional classes override the abstract run( ) method and define the tasks to be performed by threaded objects instantiated from these classes. When a thread needs to be stopped, the corresponding target variable is set to indicate that it should be stopped. The thread periodically checks the target variable and, when the target variable is set to indicate that the thread should be stopped, the thread executes one or more instructions that cause execution of the thread to complete and to exit normally.
51 Citations
24 Claims
-
1. A system, comprising:
-
a dedicated Java thread handler class which includes;
a start method that sets a target variable to indicate that a thread extending said dedicated Java thread handler class is running;
an abstract run method; and
a stop method that sets said target variable to indicate that said thread extending said Java class is to be stopped;
wherein said dedicated Java thread handler class is configured to be extended by custom thread subclasses that each includes a run method that overrides said abstract run method of said Java class, wherein said dedicated Java thread handler class does not include functionality particular to any of the custom thread subclasses, wherein said run method of one of the custom thread subclasses;
provides one or more instructions to be executed within said thread, wherein said instructions are configured to access one or more objects during execution of said thread;
provides one or more checks during execution of said thread to determine if said target variable indicates that said thread is to be stopped; and
completes execution of said run method if one of the one or more checks determines that said thread is to be stopped;
wherein completing execution of said run method if one of the one or more checks determines that said thread is to be stopped stops the thread without throwing an exception and leaves each of said one or more objects in a consistent state. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8)
-
-
9. A method, comprising:
-
defining a dedicated Java thread handler class wherein said dedicated Java thread handler class defines a first method that initializes a target variable to indicate that a thread extending said dedicated Java thread handler class is running, wherein said dedicated Java thread handler class defines a second method that sets said target variable to indicate that said thread extending said dedicated Java thread handler class is to be stopped;
instantiating an object that inherits said methods from said dedicated Java thread handler class, wherein said object includes a run method implementing one or more instructions to perform a particular task, wherein is said dedicated Java thread handler class does not include any instructions for said particular task;
creating a custom thread in which said one or more instructions are executed;
starting said custom thread;
calling said first method to initialize said target variable;
initiating execution of said run method in said custom thread;
calling said second method during execution of said run method to indicate that said custom thread is to be stopped;
said run method detecting that said target variable is set to indicate that said custom thread is to stopped; and
completing execution of said run method after said detecting;
wherein said completing execution of said run method stops the custom thread without throwing an exception and leaves one or more objects accessed by the custom thread in a consistent state. - View Dependent Claims (10, 11, 12)
-
-
13. A computer-readable storage medium containing a plurality of program instructions, wherein said program instructions define a method comprising:
-
defining a dedicated Java thread handler class wherein said dedicated Java thread handler class defines a first method that initializes a target variable to indicate that a thread extending said dedicated Java thread handler class is running, wherein said dedicated Java thread handler class defines a second method that sets said target variable to indicate that said thread extending said dedicated Java thread handler class is to be stopped;
instantiating an object that inherits said methods from said dedicated Java thread handler class, wherein said object includes a run method implementing one or more instructions to perform a particular task, wherein is said dedicated Java thread handler class does not include any instructions for said particular task;
creating a custom thread in which said one or more instructions are executed;
starting said custom thread;
calling said first method to initialize said target variable;
initiating execution of said run method in said custom thread;
calling said second method during execution of said run method to indicate that said custom thread is to be stopped;
said run method detecting that said target variable is set to indicate that said custom thread is to be stopped; and
completing execution of said run method after said detecting;
wherein said completing execution of said run method stops the custom thread without throwing an exception and leaves one or more objects accessed by the custom thread in a consistent state. - View Dependent Claims (14, 15, 16)
-
-
17. A system, comprising:
-
a dedicated Java thread handler class which includes;
a start method that sets a target variable to indicate that threads extending said dedicated Java thread handler class are running, an abstract run method, and a stop method that sets said target variable to indicate that said threads extending said Java class am to be terminated;
wherein said dedicated Java thread handler class is configured to be extended by custom thread subclasses each including a run method that overrides said abstract run method, wherein said dedicated Java thread handler class does not include functionality particular to any of the custom thread subclasses, wherein each run method provides code to be executed by a thread implementing a particular one of the subclasses including said run method; and
wherein, during execution of said thread, if said target variable is set to indicate that said thread is to be terminated, said run method is configured to complete execution to terminate the thread normally. - View Dependent Claims (18, 19, 20, 21, 22)
-
-
23. A method, comprising:
-
starting execution of a custom thread which implements a subclass of a dedicated Java thread handler class, wherein said dedicated Java thread handler class includes a start method that initializes a target variable to indicate that said custom thread is running and a stop method that sets said target variable to indicate that said custom thread is to be stopped, and wherein said subclass includes a run method that includes code executed by said custom thread, wherein the thread handler class does not include functionality particular to the custom thread;
calling said stop method during execution of said custom thread to indicate that said custom thread is to be stopped;
said run method detecting that said target variable is set to indicate that said custom thread is to be stopped; and
completing execution of said run method after said detecting;
wherein said completing execution of said run method after said detecting stops the custom thread without throwing an exception and leaves objects accessed by the custom thread in a consistent state. - View Dependent Claims (24)
-
Specification