System.out.println() makes a difference between working or not ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ted_Callier
Posted On:   Wednesday, February 18, 2004 04:37 PM

I am at a complete loss here. I am working to convert stock data to a point&figure structure. Never mind if you don't know what this is. If I print all input data before processing, everything runs just fine. However, if I drop the System.out.println() stuff, I get wrong results. Initially I thought this might be a race condition (data acquisition is on a different thread), but even wait()ing a long time doesn't help. The data are kept in an unsychronized ArrayList if this matters, however, once the data are in the ArrayList they don't change. And the routine doesn't see the data until data are complete. I am even using identical code in a different method without any problems. It's so weird, I even fail to formulate a google search for it. I    More>>

I am at a complete loss here. I am working to convert stock data to a point&figure structure. Never mind if you don't know what this is.

If I print all input data before processing, everything runs just fine. However, if I drop the System.out.println() stuff, I get wrong results. Initially I thought this might be a race condition (data acquisition is on a different thread), but even wait()ing a long time doesn't help.

The data are kept in an unsychronized ArrayList if this matters, however, once the data are in the ArrayList they don't change. And the routine doesn't see the data until data are complete.

I am even using identical code in a different method without any problems. It's so weird, I even fail to formulate a google search for it. I feel dumb asking, because it seems so obvious. But maybe someone has a clue why printing makes a difference?

Thanks,

Ted



			
if ("SIF".equals(q.getSymbol())) {
for (int i = 0; i < q.size(); i++) {
Bar b = (Bar) q.bars.get(i);
System.out.println(b.YYYYMMDD + " " + b.Open + " " + b.High + " " + b.Low + " " + b.Close + " " + b.Volume);
}
}

if (1 == 0 && "SIF".equals(q.getSymbol())) {
// doesn't work either
synchronized (this) {
try {
wait(10000);
} catch (InterruptedException ignored) {
}
}
}

XO xo = new XO(q, xoProp);


Here, the XO object shows good or bad results depending on whether I print the raw data before or not.

   <<Less

Re: System.out.println() makes a difference between working or not ?

Posted By:   Bhagyashree_Jayaram  
Posted On:   Thursday, February 19, 2004 03:56 AM

Hi,

I am unable to understand ur question properly.Are these Open,Close,High,Low are attributes or methods?If its methods then you need to enclose it with "()" like Open().
Any way give more details if this answer is not what you want.

Hope this helps...
Bhagya
About | Sitemap | Contact