Solved

threads to get the elapsed time

Posted on 2006-10-23
6
187 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet example 11 56
Desingning Refactoring existing code 2 31
collection output issue 9 59
Java array 10 55
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

735 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