This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Two threads filling one table  RSS feed

 
fedai gandjaliyev
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I have a program that sends SMS thru two mobile phones that are connected to
the PC!
And I have JTable compennt having two columns : Receipent and Status (failed, succeded)
For each I create a new thread that starts sending!
The thread is smth like this

//
result=SendSMS(receipent);
table.setValueAt(receipent, 0)
table.setValueAt(result, 1)
//
Assume that I have the 30 receipents in each thread
1 - in the first thread
2 - in the second thread
3 - in the first thread
4 - in the second thread
........................
The threads start sending messages at the same time so they will fill the table randomly but I want them to do it in sequence! How can I do it?
Waiting for reply......
Thank you!
 
Travis Hein
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i did this for a reporting app that needed to read inputs, and then process them through threads, and display the results in the same order as the original inputs.

what i did was read each input into a bean that contained a job number, or some other identifier outside of the bean itself, and build a vector of these as the inputs to the threads.

the threads would grab the items in the input vector, process them and move them to a "finished" vector.

so then i was able to use the job number i had placed into the wrapper beans in the result vector to know what it's order should be in the output list.

the idea is to not depend on the thread completion to be in the order of the inputs, and to tag or associate the results with your own concept of a row number.
 
fedai gandjaliyev
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a fine idea!
I hope it'll help me too!
Thank you!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!