473,216 Members | 1,288 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,216 software developers and data experts.

Java Thread return data

m6s
55
Expand|Select|Wrap|Line Numbers
  1. MovAvg run = new MovAvg(_symbol, this, SumDays.SMALL );
  2. threadExecutor.execute(run);
  3. Collection<Double> vl = run.getMovAvg().values();
  4.         Iterator itr = vl.iterator();
  5.         while(itr.hasNext()){
  6.             System.out.println(itr.next());
  7.         }
  8.  
This snippet generates, or at least tries to generate a Moving Average. The MovAvg is a Runnable class. I send in the symbol, the values ( a class of inherited treemap values) and the period of days ).
In order to take back the results I try the to build a Collection and then generate an iterateion on the values of this collection.

First: I have a Null exception, which I believe it has to do with the fact, that the thread might not have started yet? If so, how can I handle that the next step will be executed right after the execution of the thread ? Well what I don't see is how to "plug-in" wait, notify thing...

Second: Is it right the way I am trying to collect the values? If I have secured that the thread will run before we reach to this point...

Thank you...
Jan 11 '09 #1
6 6536
Tassos Souris
152 100+
Have a look at the java.util.concurrent.Callable interface.
It is similar to Runnable (in the sense that they can be executed by another thread), with the exception that Callable can return a result and throw a checked exception.
Also, have a look at the Future interface that provides you with methods to check if the computations are complete, to wait, and to retrieve the result of the computation specified by a Callable.

Take a look at the Java concurrent package API. There are some examples there.
Jan 11 '09 #2
m6s
55
Se efharisto.. Mallon kanei tin douleia tou...alla prepei na to dokimaso vevea...
Jan 12 '09 #3
r035198x
13,262 8TB
You are not allowed to use languages other than English in this forum.
Jan 12 '09 #4
m6s
55
OK, thank you...Probably does the work but I should try first..though
Jan 12 '09 #5
Tassos Souris
152 100+
@r035198x
You don't promote internationalization here :-)
Jan 12 '09 #6
JosAH
11,448 Expert 8TB
@Tassos Souris
It's just a practicality; if the majority of the people online would've spoken Dutch, we'd all be speaking Dutch here ;-) English is the "Lingua Franca" of the net.

kind regards,

Jos
Jan 12 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
4
by: Robert Schneider | last post by:
Hi, I have got a problem inserting data of a file (both, binary and text) into a blob column. It is created with "Data BLOB(2G)" in the sql statement (so the name of the column is obviously...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
6
by: Rhino | last post by:
I'm trying to debug a simple Java UDF written in the DB2General style within Eclipse. I'm getting a java.lang.UnsatisfiedLinkError when I execute the set() method in the UDF. I know that the...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
12
by: sandyw | last post by:
Exception in thread "main" java.lang.NullPointerException at company.Employee.inputEmployee(Employee.java:172) at company.Employee.main(Employee.java:267) which I got before... Can someone please...
2
by: josephx | last post by:
Hello, I got some of these errors listed below after executing an HTTP Post MIDlet on CLDC/MIDP platform, "Nokia S40 DP 2.0 SDK 1.1" and "S40 5th Edition SDK Feature Pack 1" and even for S60's...
2
by: ironpingwin | last post by:
Hi! I'd like to make few threads which will run in the same time in C++. I try to use boost library v 1.34.1 (it can't be newest, because I compile on remote machine, which is not...
1
by: lakshmiRam | last post by:
hi i have the below code to start bluetooth over PC to accept data from mobile but when i compile i will get the following errors i have widcom bluetooth stack and bluecove.jar and...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.