Results 1 to 3 of 3
  1. #1
    akshit is offline Member
    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    0

    Post threadmain.java:44: error: reached end of file while parsing }

    class thread1 implements Runnable{
    Thread t;
    thread1()
    {
    t=new Thread(this,"my thread");
    System.out.println("current thread : "+t);
    t.start();
    }
    public void run()
    {
    {
    try{
    for(int i=0;i<5;i++)
    {
    System.out.println("child thread" +i);
    Thread.sleep(1000);
    }
    }catch(InterruptedException e)
    {
    System.out.println("child Thread interrupted");
    }
    System.out.println("child Thread exited");
    }
    }

    class threadmain
    {
    public static void main(String args[])
    {
    new thread1();
    try
    {
    for(int i=0;i<5;i++)
    {
    System.out.println("main thread" +i);
    Thread.sleep(2000);
    }
    }catch(InterruptedException e)
    {
    System.out.println("Main Thread interrupted");
    }
    System.out.println("Main Thread exited");
    }
    }


    I m getting an error : threadmain.java:44: error: reached end of file while parsing }

    please help me

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default Re: threadmain.java:44: error: reached end of file while parsing }

    You're "run" method isn't "closed", you need another closing brace there, though I REALLY do not know why you are doubling up your braces.

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: threadmain.java:44: error: reached end of file while parsing }

    You seem to have combined the right way and the wrong way of using threads into a third, even wronger way. Leaking 'this' from inside a constructor to another running thread is a huge mistake. Why is the Thread a member of the Runnable?
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Replies: 1
    Last Post: 09-28-2011, 09:33 AM
  2. reached end of file while parsing- using bluej
    By prendergast36 in forum New To Java
    Replies: 1
    Last Post: 09-08-2011, 09:00 PM
  3. FTP parsing remote file error
    By agangaia in forum New To Java
    Replies: 0
    Last Post: 04-18-2011, 08:45 PM
  4. Replies: 1
    Last Post: 05-31-2009, 06:48 PM
  5. signaling file(s) have reached in directory
    By ashu261 in forum Advanced Java
    Replies: 0
    Last Post: 02-04-2008, 07:45 AM

Tags for this 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
  •