returning a value from Threads

returning a value from Threads

Hello I have worker pattern that uses ExecutorService to schedule Thread execution but getting stuck at some point when returning a value using Future.I have code snippet below:

ExecutorService threadPool = Executors.newFixedThreadPool(1); 
      for ( int i=1; i<4; i++ ) { 
        threadPool.submit(new JobImpl("Job ", i));

Now this passes job and i as job and jobNumber to JobImpl class:

public class JobImpl implements Runnable {

    public String job;
    public int jobNumber;
   ExecutorService executorService = Executors.newSingleThreadExecutor();
    public JobImpl( String job, int jobNumber ) {

        this.job = job;
        this.jobNumber = jobNumber;
    }
    public String getJob() {

        return this.job;
    }
    executorService.execute(new JobImpl(job,jobNumber){
    public void run(){
    String j =Integer.toString(jobNumber);
    Deque<String> jdeque = new LinkedList<String>();

        jdeque.add(job+j);      
    }
});
    Future future = executorService.submit(new JobImpl(jdeque){
    public JobImpl call() throws Exception {
        return jdeque;
    }
});

}
View Answers

May 1, 2012 at 3:49 PM

I need to return the jdeque so that I can pass it on to another process but I have a problem with the submit(Callable) method.









Related Tutorials/Questions & Answers:
returning a value from Threads
returning a value from Threads  Hello I have worker pattern that uses ExecutorService to schedule Thread execution but getting stuck at some point when returning a value using Future.I have code snippet below: ExecutorService
why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...
why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...   public class d55 { int squares = 81; public static void main(String
Advertisements
PHP Returning Values from Function
Returnig Values from function: From a function we can return values using... of the project. If we do not put any return statement then a NULL value is returned...(); echo "Value of \$var1= ".$var1."<br/>"; echo
threads
threads  what are threads? what is the use in progarmming
Reading Value From console
Reading Value From console  In case of String data Type readLine method of DataInputStream class read complete line of the given string but the next method of Scanner class doesn't read the complete line of String. why
Reading Value From console
Reading Value From console  In case of String data Type readLine method of DataInputStream class read complete line of the given string but the next method of Scanner class doesn't read the complete line of String. why
passing value from javascript popup
passing value from javascript popup  How to take user input and pass that input value using popup in Javascript
Threads
from execution 3)Allows you to run your runnable from a Thread Pool, the event
Subtract a value in the database from java
Subtract a value in the database from java   Hi, i want to know how to subtract a value on a database. im using JDBC connection from access and i want to decrement the value of table "quantity" of 1 each time it passes a loop my
Read the value from XML in java
Read the value from XML in java  Hi, i have an XML... on that file.So how can i read that value. This is little urgent for me.please help.... <param name="file" value="D:/Lakki/logs/test.log"/> <param
Return Value from One Form
Return Value from One Form  I have two buttons in main form client and bank.when i click client button new form will open, in this dedupe button... value of dedupe form and use in bank form..how to do
export value in csv from jsp
export value in csv from jsp  Hi! i have creted a html form using javascript. i hv taken the array values in jsp. nw i want to pass these array values from jsp to csv file. so please help me how to send
Retrieve Value from Table - Hibernate
Retrieve Value from Table   Hai friend, I need help, How can i retrieve values From database using hibernate in web Application. As I new to hibernate I couldn't find solution for this problem.. Can anyone help please.. 
Retrieving attribute value from XML
Retrieving attribute value from XML  I have an XML as below to parse...; ..... But am not able to fetch the value of LoadTicketId attribute. My code.../Listingnode.shtml http://www.roseindia.net/xml/getting-text-values-from-a-nodel.shtml
store value in checkbox from gridview
store value in checkbox from gridview  Please check the error... = con.createStatement(); rst=st.executeQuery("select * from books...; <input type="submit" value=" DELETE "/>&nbsp;&nbsp
Returning data from an MX item editor in Flex4
Returning Data from an MX itemEditor in Flex4: The ItemEditor control is a MX...({}); <s:Panel title="Returning data from an MX item... for return a single value to the control. You will use the editorDataField property
Return Value From Event - Java Beginners
Return Value From Event  I would like to call a method that returns a value after an event has occurred and the value is determined by the event or listener. eg: public int mymethod() { static int value=0; KeyAdapter
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
Getting environment variable value from java
Getting environment variable value from java  Getting environment variable value from java
How to save and get value from JSP
How to save and get value from JSP  Employee Name Time... 2012-12-12 save i want to save dis value jsp to action ...how can i get all value ..and store..how can its values goes ... (adsbygoogle
Retrieve value of radio button from database to form
Retrieve value of radio button from database to form  var gn=document.getElementsByName("empg"); //empg is name of radio input type. for(var i=0;i
How to read value from xml using java?
How to read value from xml using java?  Hi All, I want to read value from following xml using java.. In <Line>,data is in format of key and value pair.. i want to read only values..could u plz help me in this?Thanks
How to pass value from dijit.Tree to dijit.MenuItem - Ajax
How to pass value from dijit.Tree to dijit.MenuItem  Hi Friends, I... of 'Test' I want to show the value of that Node( which is comming from TreeNode... node whicl will apper on right click. What I have already done. From my server
how to retrieve a checkbox value(retrieve from DB)
how to retrieve a checkbox value(retrieve from DB)   I facing a problem with checkbox value that already exists inside the database. so how can I retrieve those value from another database table? the table subject and service
Assign value from a <bean:write> tag to a variable
Assign value from a tag to a variable  I am calling a stored procedure from JSP page which needs an input parameter. This input parameter needs to get the value from bean write tag . How can i do that ?   Please go
passing value from javascript to jsp - JSP-Servlet
passing value from javascript to jsp  Hi... Is there any way to get the value from the javascript and print it on the current jsp page or print an array onto the current jsp page using javascript  Hi Friend, We
get value from multiple textbox in jsp
get value from multiple textbox in jsp  how to get multiple textbox value in another jsp? If i using the following code <%for(int i=0;i<3;i++) {%> <td>name<input type="text" class="name" id="name">
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Hii Sir, Lots of thnx to ur reply .I went through both... of selecting value from autocomplete textbox using jquery in jsp from mysql database
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database. ... but was unable to find out exact way to fullfill the solution of selecting value from autocomplete textbox using jquery in jsp from mysql database. Kindly send me
how to select the row value that was retrived from the database ?
how to select the row value that was retrived from the database ?  I am getting the data's from the table that was stored in database. Now in the page in which i am getting all the data from the database has an another select
how to select the row value that was retrived from the database ?
how to select the row value that was retrived from the database ?  I am getting the data's from the table that was stored in database. Now in the page in which i am getting all the data from the database has an another select
check radio button on retrieving the value from database.
check radio button on retrieving the value from database.  HI i am new to jsp.In my applcation i having a problem. I am retrieving user payment from... information from database the i want to show cash radio button checked.How can i do
Find Cylinder area By inputting value from user
Find Cylinder area By inputting value from user  Hello Sir I need the code for calculating the area of a cylinder in which it asks radius value from user and then calculate area using this radius value. Please provide me
How to add value from sql server in dropdownlist
How to add value from sql server in dropdownlist  I have created a hospital management project using jsp servlet, where one form name is patient... id from other table like out patient, and this id will be stored dynamically
retrieving of value from excel file - JSP-Servlet
retrieving of value from excel file  Dear sir, Thanks for sending a code now i am getting a particular column value i.e EmailId column... onl single column value i.e EmailId values to send for a different employees
read value from database & alert it is available in database or not
read value from database & alert it is available in database or not  how to read value from text box and alert whether it is available in database...="text/javascript"> function check(value){ xmlHttp=GetXmlHttpObject() var
value in div from php, reloading form
value in div from php, reloading form  I am having one form with name... in which i am showing the value if not registered .but what is happening is I am..." name="name" value="<?php echo $name?>" required></td></tr>
How to pass the value from controller to jsp page ?
How to pass the value from controller to jsp page ?  HI I need to pass the value from controller to jsp. I use the way like this (adsbygoogle = window.adsbygoogle || []).push({}); Controller
getting unique value from java.util.random - Java Beginners
getting unique value from java.util.random  i am doing a shopping... for that i used java.util.random to get random productid from product table, but the value which i am getting contains duplicate values and it is not unique, my
Retrieving value from multiple table in database
Retrieving value from multiple table in database  Hi fnds, I want... FROM ( SELECT * FROM month1 UNION ALL SELECT * FROM month2 UNION ALL SELECT * FROM month3 ) AS somealias GROUP BY uname
retrieving of value from excel file - JSP-Servlet
retrieving of value from excel file  Dear sir, Thanks for sending... this message to all the employees when i upload a file then it fetch a data from that excel sheet i.e this matter will take a para meter values from the excel
retrieving of value from excel file - JSP-Servlet
retrieving of value from excel file  Dear sir, Thanks for sending... this message to all the employees when i upload a file then it fetch a data from that excel sheet i.e this matter will take a para meter values from the excel
help to select a value from the dropdown list
help to select a value from the dropdown list  I have a html file... <input type="text" size="30" name="inputString" value="" id="inputString...?inputString=' + document.getSelection("inputString").value; } </script>
getting null value in action from ajax call
getting null value in action from ajax call  Getting null value from...; ... <tr> <td><s:label value="Course " for="course... populateTwo(String id1) { // Get null value for id1
getting null value in action from ajax call
getting null value in action from ajax call  Getting null value from...; ... <tr> <td><s:label value="Course " for="course... populateTwo(String id1) { // Get null value for id1
getting null value in action from ajax call
getting null value in action from ajax call  Getting null value from...; ... <tr> <td><s:label value="Course " for="course... populateTwo(String id1) { // Get null value for id1
get the value from another class - Java Beginners
get the value from another class  Hello to all, I have stupid question. I have main.java and ConfigXML.java(read my config xml file). Code from...)).getNodeValue().trim(); from my ConfigXML.java in main.java. Sorry for my bad
PHP Array get key from value
In php array one can get the key from value by the use of array_search function Array_search function searches the key for the given values in the array. Example of PHP Array Get Key from Value <?php $product=array

Ads