Results 1 to 3 of 3

Thread: Threading In Java

  1. #1

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    Threading In Java

    How can I thread in java? In vb you can use application.DoEvents and that way your application doesnt freeze when its doing something. How can I do this with Java?


    To make things clearer, this is what Im doing. I am simply opening a file and adding each line into a DefaultListModel and then Im setting that model to a JList. While this happens it is freezing the app, since the file is fairly large. If I use threading will this stop the application from freezing? Is there something else I can do?

    I appreciate the help.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Threading In Java

    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3
    Member
    Join Date
    May 2006
    Posts
    32

    Re: Threading In Java

    Java Code:
    1. class myThread extends Thread {
    2.     public void run() //runs when you start the thread
    3.     {
    4.         while(true)
    5.         {
    6.         }
    7.     }
    8. }
    9.  
    10. public class myProgram {
    11.     public static void main(String[] args) {
    12.         Thread newThread = new myThread();
    13.         newThread.start(); //starts the thread
    14.     }
    15. }

    myThread will run seperately from your main myProgram thread.

Posting Permissions

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



Click Here to Expand Forum to Full Width