Solved

threads to get the elapsed time

Posted on 2006-10-23
6
183 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
Comment Utility
elapsed time of what?
0
 

Author Comment

by:cutie_smily
Comment Utility


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
Comment Utility
why wouldn't it be 5 minutes :)

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

0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:cutie_smily
Comment Utility


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
Comment Utility
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
Comment Utility
> use whjat i posted above
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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)
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

744 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now