The moose likes Java in General and the fly likes System Time within Run method of a thread??? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "System Time within Run method of a thread???" Watch "System Time within Run method of a thread???" New topic
Author

System Time within Run method of a thread???

Terence Fernandes
Greenhorn

Joined: Oct 25, 2005
Posts: 4
I need to get the system time within the Run() method of the thread. I have tried eveything but somehow cant find an answer.


eg: public void run(){

Date date = new Date();
date = date.getTime();
}

I get a NULL POINTER EXCEPTION HERE.

Please help.

Thanks

Terence
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
What you have shown should not even compile.

It should yield a "incompatible types" compile time error.

Regards, Guy
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Is there something wrong with:



What does it being in the run method of a thread have to do with it exactly?
[ October 25, 2005: Message edited by: Ken Blair ]
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
Originally posted by Ken Blair:
Is there something wrong with:



What does it being in the run method of a thread have to do with it exactly?

[ October 25, 2005: Message edited by: Ken Blair ]


That code and:




are (essentially) equivalent.

Guy
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Okay, remove the call to System since they're the same thing. The rest of what I said stands...what's wrong with it and what does it being in run have to do with anything.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Ken Blair:
what's wrong with it and what does it being in run have to do with anything.


Nothing, and nothing. The problem must be something else.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Terence Fernandes
Greenhorn

Joined: Oct 25, 2005
Posts: 4
Yeah....the problem was in the way I was calling the Date. I figured out the whole issue.
Thanks a lot guys.
Regards
Terence
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: System Time within Run method of a thread???
 
Similar Threads
cant print Date or time
sending email
Date & Time
sending email
Interruptinh thread