Can you explain what the program does? What does "not working" mean?
Type: Posts; User: Norm
Can you explain what the program does? What does "not working" mean?
If all the jobs are in an array, then pass each thread indexes into the array for the first and last job it is to process.
For N jobs and T threads
first thread gets: 0, N/T-1
second thread gets:...
Give each thread N/i jobs
How are the "jobs" defined and created? Do you know how many "jobs" will be created? Can you differentiate between one "job" and another?
Is there a first "job" and a second "job" and a third "job"...
It depends on how the jobs are defined. See my example in post#36
If the jobs were: 1,2,3,4,5,6 and there were 3 threads
Then the jobs could be assigned this way:
thread one does jobs 1 & 2...
Do you see how to compute which jobs are assigned to each thread?
Divide the number of jobs by the number of threads and allocate the jobs from that.
Does that mean this?
Say there are 6 jobs and 3 threads:
thread one does jobs 1 & 2
thread two does jobs 3 & 4
thread three does jobs 5 & 6
Post the code that you are having problems using threads in and explain what the threads are supposed to do.
The last problem had nothing to do with trying to do parallel processing using threads.
Is this "job" some data being written to a file
or is it the execution of some code?
The use of the word jobs is ambiguous for me.
How does the code control which thread gets which "job"? Is...
The Scanner class has methods for reading from text files.
Can you explain why you want to use threads.
What do you mean by "job"
what is to be shared?
There were several error messages mixed in with the program's output.
In this one there was a varible with a null value at line 113. Look at line 113, find the variable that had a null value and...
Please copy the full text of the error message and paste it here.
Look at the line where the NPE happens, find the variable with the null value and backtrack in the code to see why that variable...
That makes it easier to read and understand.
Now you need to move the open and close of the file outside the loop.
Every time you open a file, write to it and close it, the file's previous...
Did you see the steps I suggested for the program in post#15?
Here they are again:
Open some output files to write items to<<<<The files are all opened BEFORE the loop
loop through a list of...
Did you notice after posting the above that the code was not formatted?
Is that what you wanted to happen?
If not, please explain what you want the code to do that it did not do.
Did you...
Now try writing the code to do it.
Your posts have been made visible now.
Is this what you are trying to do:
Open some output files to write items to
loop through a list of items
write item to one of the files based on its...
You should define the String: outputFileName before the if statements, not inside of them where they are local variables known only inside the if. You can assign a value to the String inside the if...
Can you make a list of the steps the program should take to do it job? When will it open each file?
When will it write a record to a file? When will it close each file?
Please edit your post...
Question moved from Member Introductions section.
What part of the program are you having problems with?
The decision part has been specified here:
If the files are text files, look at using...