Results 1 to 3 of 3
  1. #1
    ElvisMachuca is offline Member
    Join Date
    Jan 2013
    Posts
    32
    Rep Power
    0

    Default How to make java not get stuck while performing String operation

    Hi,

    I am working on a compression class. So far, I can get the program to compress 100 bytes to 44 bytes. However, when I increase the block size, or I mean the amount of data in the buffer, it takes java alot longer to finish the program. Even though the program is running on a thread. Java gets stuck, and I have to wait long before it finish the compression task. Not to mention the same thing, hanging over when performing the decompression task.

    Let me put it into perspective: (the numbers are from actual code running in a thread):

    Let say compressing 100 bytes takes 609 milliseconds. Not bad, barely a second. However, 200 bytes, takes 1.702 seconds + milliseconds. Thats 1.093 seconds + milliseconds more than the previous 100 byte task. Now with 300 bytes takes 3.415 seconds + milliseconds. Thats again, 1.713 seconds, or 62 milliseconds more than previous 200 bytes task. And Lastly, 400 bytes takes 6.757 seconds + milliseconds, thats 3.342 seconds + milliseconds more, or 1.629 seconds + milliseconds more than the previous 300 byte task.

    What I am trying to say, is that the task is taking too long to finish. Is there a way to go around this. I know that threads make things concurrent, but even like this is taking too long.

    Help anyone.

    I mean the reason the program is taking so long is because it is performing string operations.

    Is there a way to make java perform faster under string operation work load?
    Last edited by ElvisMachuca; 01-31-2013 at 04:58 PM.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: How to make java not get stuck while performing String operation

    If you want help, I suggest you provide an SSCCE showing the benchmark you want to improve.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,305
    Blog Entries
    7
    Rep Power
    20

    Default Re: How to make java not get stuck while performing String operation

    Also read the API focumentation for the StringBuilder class (or if you prefer: the StringBuffer class).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. How Can i already be stuck? String play java
    By tripline in forum New To Java
    Replies: 1
    Last Post: 10-30-2011, 01:06 AM
  2. OUt of memery error while using string split operation
    By sheetalmuskan in forum New To Java
    Replies: 10
    Last Post: 07-12-2011, 12:36 PM
  3. Replies: 3
    Last Post: 01-11-2011, 11:45 PM
  4. Performing Exponentiation in Java without the Math Class
    By BlueJ Coder in forum New To Java
    Replies: 9
    Last Post: 10-14-2009, 08:48 PM
  5. How to make Java see a string as html
    By matpj in forum Java Applets
    Replies: 4
    Last Post: 09-26-2008, 03:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •