multithreading - java down counter class -
I have applied a down counter to Java in a different class whose zero starting time is starting at zero But
public class stopwatch {static int interval; Stable timer timer; Public Zero Start (Int Time) {Scanner sc = New scanner (System.in); Int delay = 1000; Int duration = 1000; Timer = new timer (); Interval = time; Timer.scheduleAtFixedRate (new timer Task) (public zero-zero) {// System.out.println (setInterval ()); Set interval ();}}, delay, duration); } Public at Time () {Return Interval; } Private Static Last Interval Set () (if (Interval == 1) timer.cancel (); Return - Interval;}}
Thanks in advance.
Depending on what other thread is doing, I am in the middle of a bouleviation value set (or checked in another thread) If the other thread's execution can be stopped at any time using an obstacle, although execution can not be stopped after a certain time. , Then check / set the bullion before entering that code.
Boolean in your stopwatch class:
Private static Boolean release = true;
Make a method to check boolean:
requires public static boolean () {return this.continue;}
Modify your setInterval ()
to change the boolean:
private static last int setInterval () {if (interval == 1) release = false; return - Interval;}
Somewhere Add in Czech number two sections:
if (! (Stopwatch.shouldContinue ())) {return; }
or
if (stopwatch. Shield Continuity ()) {// work here}
It seems like my comment, I thought I would make it in a reply so that we could remove it from the unanswered list.
Comments
Post a Comment