This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SimpleDateFormat thread problems?


I suspect part of the problem is possibly broken/slow stack trace code trying to call external programs to do a calling-classloader check.

Could you try this patch? It should fix the performance bug, but it seems strange that it would cause your thread to hang. Particularly if the problem only occurs in a threaded environment, it may be that there are thread race/synchronization problems with your code. Make sure you are synchronizing your threads correctly.

Bryce


Vladimir Leven wrote:


This is a bit vague, but maybe someone on this list will have some insights...

I have some simple Java code that runs in two threads. One thread runs a command line interface. Another thread runs a job scheduler. The job scheduler has a method that returns some stats as a string (e.g. scheduler start time, number of jobs processed so far, etc...). From the command line thread, I can ask for these stats. It seems that after asking for stats a few times, the job scheduler thread hangs, i.e. every time I ask for the stats, I get the same result. If I remove the SimpleDateFormat code that prints the date information in a human-readable way, this problem seems to go away. The stats command also runs noticeably faster.

Thanks for any help...


Index: java/util/Calendar.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/Calendar.java,v
retrieving revision 1.19
diff -u -r1.19 Calendar.java
--- java/util/Calendar.java	7 May 2004 04:18:19 -0000	1.19
+++ java/util/Calendar.java	10 May 2004 17:42:17 -0000
@@ -376,7 +376,8 @@
    */
   private static ResourceBundle getBundle(Locale locale) 
   {
-    return ResourceBundle.getBundle(bundleName, locale);
+    return ResourceBundle.getBundle(bundleName, locale,
+      Calendar.class.getClassLoader());
   }
 
   /**
Index: java/text/DateFormat.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/DateFormat.java,v
retrieving revision 1.13
diff -u -r1.13 DateFormat.java
--- java/text/DateFormat.java	20 Apr 2004 14:45:02 -0000	1.13
+++ java/text/DateFormat.java	10 May 2004 17:42:17 -0000
@@ -325,7 +325,7 @@
     try
       {
 	res = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
-				       loc);
+				       loc, DateFormat.class.getClassLoader());
       }
     catch (MissingResourceException x)
       {
Index: java/text/DateFormatSymbols.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/DateFormatSymbols.java,v
retrieving revision 1.15
diff -u -r1.15 DateFormatSymbols.java
--- java/text/DateFormatSymbols.java	20 Apr 2004 14:45:04 -0000	1.15
+++ java/text/DateFormatSymbols.java	10 May 2004 17:42:18 -0000
@@ -98,7 +98,8 @@
   public DateFormatSymbols (Locale locale) throws MissingResourceException
   {
     ResourceBundle res
-      = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation", locale);
+      = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation", locale,
+      				 getClass().getClassLoader());
 
     ampms = res.getStringArray ("ampms");
     eras = res.getStringArray ("eras");

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]