Hey all, small problem with homework 1021 (threading)-
I get 10 of the same timestamp for each thread. Ex-
06:02:49:972 -0500 on 10/26/2009
06:02:49:983 -0500 on 10/26/2009
06:02:49:983 -0500 on 10/26/2009
06:02:49:972 -0500 on 10/26/2009
06:02:49:983 -0500 on 10/26/2009
06:02:49:983 -0500 on 10/26/2009
06:02:49:972 -0500 on 10/26/2009
06:02:49:983 -0500 on 10/26/2009
06:02:49:983 -0500 on 10/26/2009
Over and over again. Why is the timestamp not changing with each call of
getTime() ?
Relevant tidbits of code:
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss:SS Z 'on'
MM/dd/yyyy");
public void run()
{
for (int i=0; i<10; i++)
{
System.out.println(sdf.format(cal.getTime())) ;
try {
Thread.sleep(100);
} catch (InterruptedException e) {}
}
}
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---