Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception when ThreadLocal.set() is called.  RSS feed

 
shahabas shabeer
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My application throws a java.lang.Exception when it call ThreadLocal.set() method. This happens only during load test with 1000 concurrent virtual users. I never got this error during development and could not reproduce in my development machine. So I guess the issue is with thread management. Should I call this method in a thread safe manner?. What would happen if I did not synchronize the method?. Will the application throw java.lang.Exception if two threads try to update this value at the same time? Any help would be highly appreciated.

Thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there no message associated with the exception? If not, are you sure that your code isn't swallowing and re-throwing a more informative exception?
 
shahabas shabeer
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope.. There is no clear message in the exception. I do have a try-catch block but I am printing the entire exception details using printStackTrace() method.
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds, ummm, suspicious. I suggest posting the complete stack trace, along with the exact JDK version number and OS that you're using.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!