Start Thread
list<actiondevice> temdevice = new arraylist<actiondevice > ();
Scheduleeexcutethread set= New Scheduleeexcutethread (temdevice);
Set.start ();
Parameters Temdevice is the object that needs to be manipulated.
Parameters Actiondevice as an entity class
ThreadsScheduleeexcutethreadneed to inheritThread
p Ublic &NBSP; class scheduleeexcutethread extends
logger = logger. getlogger Span style= "font-family: ' Courier New '; Color:rgb (0,0,0); font-size:13px;" > (Class. class .getname ());
p Ublic list< actiondevice> Dealy &NBSP;=&NBSP; new arraylist< Actiondevice> ();
p Ublic list< actiondevice> Tempdealy &NBSP;=&NBSP; Span style= "font-family: ' Courier New '; Color:rgb (127,0,85); font-weight:bold;font-size:13px;" >new &NBSP; a rraylist<actiondevice> ();
Boolean Stop = false ;
Public scheduleeexcutethread(list<actiondevice> ddealy) {
this . dealy =ddealy;
}
Public void run () {
while (! Stop ){
for (actiondevice adevice:dealy) {
Adding a temporary list to an object that does not meet the criteria
tempdealy. Add (adevice);
}
dealy. Clear ();
dealy. AddAll (tempdealy);
tempdealy. Clear ();
if ( dealy .size () ==0) {
this =
}else{
try {
thread. sleep ();
} catch (Interruptedexception e) {
e.printstacktrace ();
}
}
}
}
}
Defining Parameters Stop , when the condition is ripe, set stop=true; waiting for the next thread to start, it will determine stop=true , and then the process ends.
Scheduleeexcutethread set= New Scheduleeexcutethread (temdevice);
Set.start ();
Call thead for a background thread