Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Thread Hangs at split method.

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thread Hangs at split method.

    Hi,

    When i am trying to run the following code in a loop in my application my thread is hanging the server.
        /**
         * Finds the separator for time string.
         * 
         * @param timeString time as a string.
         * @return separator.
         */
        private static String findSeparator(String timeString)
        {
            String separator = ":";
            if (timeString != null)
            {
                if (timeString.indexOf(separator) == -1)
                {
                    separator = "\.";
                }
            }
            return separator;
        }
     
        /**
         * Convert the time in HH:MM to time in minutes.
         * 
         * @param timeString time string to be converted (HH:MM:SS).
         * @return the time in HH:MM to time in minutes.
         */
        public static int toMinutes(String timeString, String separator)
        {
            Assert.isTrue(validateTimeString(timeString, separator), "Invalid Time String ["
                    + timeString + "]");
     
            String[] timeParts = timeString.split(separator);
     
            int hrs = Integer.parseInt(timeParts[0]);
            int mins = Integer.parseInt(timeParts[1]);
     
            return (hrs * 60) + mins;
        }
     
        /**
         * Convert the time in HH:MM to time in minutes.
         * 
         * @param timeString time string to be converted (HH:MM:SS).
         * @return the time in HH:MM to time in minutes.
         */
        public static int toMinutes(String timeString)
        {
            int minutes = 0;
     
            if (timeString != null)
            {
                String separator = findSeparator(timeString);
     
                minutes = toMinutes(timeString, separator);
            }
            return minutes;
        }

    below is log.

    [11/23/10 16:58:13:232 CET] 00000027 ThreadMonitor W WSVR0605W: Thread "WebContainer : 1" (00000022) has been active for 720641 milliseconds and may be hung. There is/are 1 thread(s) in total in the server that may be hung.
    at java.util.regex.Pattern.atom(Pattern.java:1885)
    at java.util.regex.Pattern.sequence(Pattern.java:1794 )
    at java.util.regex.Pattern.expr(Pattern.java:1687)
    at java.util.regex.Pattern.compile(Pattern.java:1397)
    at java.util.regex.Pattern.<init>(Pattern.java:1124)
    at java.util.regex.Pattern.compile(Pattern.java:817)
    at java.lang.String.split(String.java:2103)
    at java.lang.String.split(String.java:2145)

    Please help.

    Thank you.
    Kailas
    Last edited by helloworld922; November 25th, 2010 at 09:55 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,262
    Thanks
    176
    Thanked 820 Times in 763 Posts
    Blog Entries
    5

    Default Re: Thread Hangs at split method.

    separator = "\.";
    Does the above code actually compile? I presume you are calling the function toMinutes(String timeString)?

Similar Threads

  1. Can i call init() method in destroy method.?
    By muralidhar in forum Java Servlet
    Replies: 1
    Last Post: October 22nd, 2010, 11:18 AM
  2. MVC - Split the Java servlet(help needed)
    By kamweshi in forum Java Servlet
    Replies: 1
    Last Post: October 18th, 2010, 09:02 AM
  3. Thread to EDT
    By Asido in forum Threads
    Replies: 3
    Last Post: October 15th, 2010, 01:13 PM
  4. Is thread the best option?
    By 256mxr in forum Threads
    Replies: 1
    Last Post: May 22nd, 2010, 08:24 PM
  5. Thread and connection
    By Param in forum Threads
    Replies: 0
    Last Post: April 26th, 2010, 03:43 AM