Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SimpleDateFromat class problem  RSS feed

 
Srinivasa Kadiyala
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read in the java doc that this is not thread safe

which Date class can I use for thread safety in Servlets ( Struts frame work)

Thanks in advance
 
Daniel Mayer
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use SimpleDateFormat - you just have to make sure that the same instance isn't used at the same time in different threads.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any local variable inside a method should be ok. Every thread gets its own set of local variables as it comes through the method. Member variables are shared by all threads and can get you in trouble.
 
Srinivasa Kadiyala
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stan & Dan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!