Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Thread Stopping unexpectedly !!!

Status
Not open for further replies.

aryajur

Programmer
Jul 2, 2003
45
US
I am running this thread in one of my programs but the strange thing is as long as I have the initial value of i as 2 3 4 or anything like here its 100 it works fine but as soon as I put it 0 or 1, the thread just runs once and then ends !
What is going on ?? Please help !!!


public class MyThread extends Thread
{

private DataParser dataParser = new DataParser();

public BluetoothInput ()
{
}
public void run()
{
while (true)
{

for(short i=100;i<=10000;i+=123)
{
DataParser.parseAll(i);
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
}
}
}
}
}
 
>> What is going on ??

No idea, but if DataParser.parseAll(i); throws an exception then the thread would exit since it is unhandled.

Why do you create a new DataParser as a private member and then never use it?
Code:
private DataParser dataParser = new DataParser();


-pete
 
Hello,

I am sorry it was a spelling mistake ! it was supposed to be:

dataParser.parseAll(i);

and dataParser.parseAll(i); does not throw any exception. If it would have thrown an unhandled exception it would have shown in the J2ME wireless toolkit console wondows as it shows unhandled exceptions. But it does not show anything !
Any other ideas??
 
If it would have thrown an unhandled exception it would have shown in the J2ME wireless toolkit console wondows as it shows unhandled exceptions..
Suggestion: Don't be %100 sure from that.But in order to be %100 sure try replacing the code
public class MyThread extends Thread
{

private DataParser dataParser = new DataParser();

public BluetoothInput ()
{
}
public void run()
{
while (true)
{

try
{
for(short i=100;i<=10000;i+=123)
{
DataParser.parseAll(i);
Thread.sleep(1000);
}
}

catch (Exception e)
{
//do something so that you will see what
//goes on here...
}
}
}
}

Salih Sipahi
Software Engineer.
City of Istanbul Turkey
s.sipahi@sahinlerholding.com.tr
 
Ya Thanks I found it. It was an exception in dataParser. a divide by 0 arithmetic Exception. thanks guys !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top