473,326 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Exception in Thread error

While I was studying from the book, I copy this program and try to compile
and did not work.
Please help

/* It start here **/
import java.lang.*;

public class CountDown implements Runnable
{
static int cycles = 10 ;
public static void main(String[] args )
{
int mx = Integer.parseInt( args[0] ) ;

for( int n = 0 ; n < mx ; n++ )
{
Runnable cdown = new CountDown( n );
Thread t = new Thread( cdown );
t.start();
}
}

int myNum ;
CountDown( int n )
{
myNum = n ;
}

public void run()
{
for( int i = cycles ; i >= 0 ; i-- )
{
System.out.println( myNum + " = " + i );

try
{
Thread.sleep( 1000 );
}

catch(InterruptedException e)
{
}
}
}
} // end of the CountDown class

/* end **/

Jul 17 '05 #1
1 1726
yu859sem wrote:
While I was studying from the book, I copy this program and try to compile
and did not work.
Please help

/* It start here **/
import java.lang.*;

public class CountDown implements Runnable
{
static int cycles = 10 ;
public static void main(String[] args )
{
int mx = Integer.parseInt( args[0] ) ;

for( int n = 0 ; n < mx ; n++ )
{
Runnable cdown = new CountDown( n );
Thread t = new Thread( cdown );
t.start();
}
}

int myNum ;
CountDown( int n )
{
myNum = n ;
}

public void run()
{
for( int i = cycles ; i >= 0 ; i-- )
{
System.out.println( myNum + " = " + i );

try
{
Thread.sleep( 1000 );
}

catch(InterruptedException e)
{
}
}
}
} // end of the CountDown class

/* end **/

The program is fine. Just think about where the program gets it's *mx
value* .. Look at the following statement!

int mx = Integer.parseInt( *args[0]* )

--
Thanks in Advance...
IchBin
__________________________________________________ ________________________

'Laughter is inner jogging'
- Norman Cousins, editor and author (1915-1990)
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
4
by: Bhavya Shah | last post by:
Hello, I am facing a very strange problem in my application. I have a form on which I select a path. I open the FolderBrowserDialog for path selection. Once the path is selected I press a button...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
2
by: akameswaran | last post by:
Admittedly this problem causes no actual functional issues aside from an occasional error message when the program exits. The error is: Unhandled exception in thread started by Error in...
6
by: Steve | last post by:
Hi All I have a windows forms Application (SAM) in vb.net 2008 using .net framework V2 One and only one customer out of 30 customers is getting errors daily where they have to close and...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.