[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

threads to get the elapsed time

Posted on 2006-10-23
6
Medium Priority
?
196 Views
Last Modified: 2010-03-31

Can anyone write a piece of code where thread sleeps every 5 minutes. calculate elapsed time (each time get the system time and compare with the last value )(hours, minutes,seconds)
0
Comment
Question by:cutie_smily
  • 3
  • 2
6 Comments
 
LVL 92

Accepted Solution

by:
objects earned 600 total points
ID: 17792627
elapsed time of what?
0
 

Author Comment

by:cutie_smily
ID: 17792752


get system time every 5 minutes and calculate the difference in time from the last time you got the system date
0
 
LVL 92

Expert Comment

by:objects
ID: 17792797
why wouldn't it be 5 minutes :)

long a = System.currentTimeInMillis();
Thread.sleep(5*60*1000);
long b = System.currentTimeInMillis();

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:cutie_smily
ID: 17792819


for instance now the system time is 8:55:40

after 5 minutes

system time will be 9:00:40

time diffrence= 5 minutes.

a program to calculate time difference..
0
 
LVL 9

Assisted Solution

by:shinobun
shinobun earned 150 total points
ID: 17793223
long a = System.currentTimeInMillis();
Thread.sleep(5*60*1000);
long b = System.currentTimeInMillis();

b - a = the elapsed milliseconds.  You can calculate from there.
0
 
LVL 92

Expert Comment

by:objects
ID: 17793257
> use whjat i posted above
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month18 days, 4 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question