Results 1 to 3 of 3
  1. #1
    becool007 is offline Member
    Join Date
    Oct 2009
    Posts
    2
    Rep Power
    0

    Default Doing a background job and not stall whole applet

    Ive been developing a 3D game. So far I was able to
    - Download cache to clients computer
    - Use the cache
    Now. I have two engines, one for the main processing and the other for the graphics. For the gfx engine to work it needs the main engine to finish what its doing or specifically whatever it has started. So in case 3, which is the third case during startup is that it downloads a GIANT 100mb cache file. During this download the Applet seems to freeze. Thats the problem. The code for my downloader is as so (Please do not copy, make your own):

    Java Code:
      public SaveFile(String url, File file) {
    
            try {
    
    	URL vs_site = new URL(url);
            FileOutputStream out = null;
            InputStream in = null;
            
            try {           
                byte buf[] = new byte[4 * 1024]; // 4kb buffer
                int read = -1;
                in = vs_site.openStream();
    
                out = new FileOutputStream(file);
                while((read = in.read(buf)) != -1) {
                 out.write(buf, 0, read);
                }
                
                out.flush();
                } finally {
                    if (in != null) in.close();
                    if (out!= null) out.close();
                }
            } catch (IOException ioe) {
                System.err.println("Error Saving " + ioe);
            }
            
        }
    So like i said durng step 3, it calls this procedure but the URL links to a 100MB file. And during the download the applet shows white. And as i also said the reason behind this is that the second this procedure starts the program has to complete it before the graphics engine gets a go.

    ~becool
    Thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  3. #3
    becool007 is offline Member
    Join Date
    Oct 2009
    Posts
    2
    Rep Power
    0

    Default

    ... What ? Splash screen has nothing to do with this. I have a loading screen. Which saves a file and when ur saving it the problem is that it holds the application. About the background thread. Care to elaborate lol. How would i do this ???

Similar Threads

  1. How to Run a .exe in background???
    By jazz2k8 in forum New To Java
    Replies: 9
    Last Post: 01-21-2011, 12:27 PM
  2. Background Image of Applet
    By BangJava in forum Java Applets
    Replies: 8
    Last Post: 11-24-2010, 06:48 AM
  3. want to run my midlet in background!
    By jackofall in forum CLDC and MIDP
    Replies: 1
    Last Post: 03-31-2009, 08:14 PM
  4. BackGround & ForeGround
    By hungleon88 in forum Advanced Java
    Replies: 3
    Last Post: 08-31-2008, 08:20 AM
  5. Set the background in Java
    By barney in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 08:13 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
  •