0

on a multi thread application, there are locked threads, as i get the threaddump, it seems to be about the java.util.Calendar class, the object is created using Calendar.getInstance() which returns new Instance. Do you have any comment. here is a sample of the thread dump;

"QuartzScheduler_Worker-128" prio=10 tid=0x00007f48844fe800 nid=0xb75f runnable [0x00007f43f01bd000]
   java.lang.Thread.State: RUNNABLE
       at java.util.SimpleTimeZone.getOffset(SimpleTimeZone.java:656)
       - locked <0x00007f4950c99780> (a java.util.SimpleTimeZone)
       at java.util.SimpleTimeZone.getOffsets(SimpleTimeZone.java:550)
       at java.util.SimpleTimeZone.getOffset(SimpleTimeZone.java:522)
       ...


"QuartzScheduler_Worker-124" prio=10 tid=0x00007f48844f6800 nid=0xb75a waiting for monitor entry [0x00007f43f05c3000]
   java.lang.Thread.State: BLOCKED (on object monitor)
       at java.util.SimpleTimeZone.getOffsets(SimpleTimeZone.java:533)
       - waiting to lock <0x00007f4950c99780> (a java.util.SimpleTimeZone)
       at java.util.SimpleTimeZone.getOffset(SimpleTimeZone.java:522)
       at java.util.SimpleTimeZone.inDaylightTime(SimpleTimeZone.java:834)
       at sun.util.calendar.ZoneInfo.getOffsets(ZoneInfo.java:282)
       ...

EDIT: jdk version is 1.6._021

dursun
  • 1,861
  • 2
  • 21
  • 38
  • Are you creating one object of Calendar and sharing amongst threads or do you have a single object per thread? Calendar is not thread safe so you must do the latter. – shazin Sep 22 '14 at 06:59
  • Calendar is created for every thread using the Calendar.getInstance method which returns new Calendar object. – dursun Sep 22 '14 at 07:10

1 Answers1

0

I think you just managed to take a thread dump at the instant that two threads were contending over the lock on a shared SimpleTimeZone object. One thread holds the lock and is runnable. The other thread is waiting for the lock.

There is nothing particularly note-worthy about this ... to my mind.

(I can't find the source-code online that gives a precise match to those line-numbers. But the versions of java.util.SimpleTimeZone that I can find don't reveal anything interesting. Hint: in the JDK for the precise version of Java that you are using, you should find a ZIP file of source code for the libraries. Look at the sourcecode for this class ....)

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216