java - Updating Calendar.SECOND in while loop -


My aim is to run a program in Java that lists the code at a certain time every day.

I know about Timer Tasks and Timer utilities but one of the reasons for not using them is that most of my code is run under loop, the condition is that the thread is still alive .

Some announcements:

  Fixed Ent Horror; Fixed int minute; Stable intexcode;   

The beginning of my time loop:

  while (this.threadAlive) {System.out.println ("Start thread"); TheHour = thetime.get (calendars.HOUR_OF_DAY); TheMinute = theTime.get (Calendar. MNUTE); TheSecond = theTime.get (calendar. SECOND); System.out.println ("second:" + second); // ... // ... // try {if (theHour == 12 & amp; amp; amp; amp; & amp; amp; & amp; amp; amp; amp; Amp; amp; amp; amp; amp; & amp; (second & gt; = 0; second & lt; 10)) {System.out.println ("in the loop"); If (super.connectToDevice ()) // // Send the data command to //out.println(COMMAND_GP; System.out.println ("Midnight simulation is successful"); // Read and Return data from device Data String data = In.readLine (); Data to send "test GPS data"; // DATAForProcessing (data) to close the data; // Disconnect from device super.disconnectFromDevice ();}} // Any exception here Hold   

Result in console after about 10 seconds of the runtime:

  START thread is second: 46 START Second thread: 46 start thread is second: 46 start thread is second: 46 start thread is second: 46 start thread is second: 46 start thread is second: 46 start thread is second: 46 start thread is second: 46   

The result I get for youcond , but it is never updated again after going through the loop. My announcement has been set globally in class and I To declare them as int I tried, but it did not make any difference. What is it that I am doing wrong?

The following will solve your problem:

Adding it to the beginning of your loop Try:

  Calendar Time = Calendar. Just Instance ();   

Thanks!

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -