Solved

threads to get the elapsed time

Posted on 2006-10-23
6
185 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 200 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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 50 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
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.

774 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