• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Please Help : Need Help on Threading

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please Help
 
KunwarAbhay Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Example.java]


[TestFind.java]



Hi all, I am having these 2 classes where the class TestFind.java writes the value of 'i' to a properties file. Now Example.java calls up TestFind.java 3 times using ExecutorService, what I want is to store the vale of 'i' in properties file every time Testfind.java is being called i.e. if its being called 3 times from Example.java then in properties file 6 times the value of i must get stored (as in every call to TestFind.java it stores 2 values of 'i' in properties file)

Please Help................







 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would advice you to refactor you code, replace the while loop with a for loop, rename the variables (what does i, j and k mean/do?) and you'll need to provide the variable x with a constructor in TestFindThread.

But I'm not totally convinced that this is going to work since you're trying to write from multiple threads into a single file.
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having trouble compiling the example files. There may be a few errors:
Did you mean to type <>=?
Do you want to declare, and initalize the variable countX somewhere?
Is there a constructor that matches TestFindThread(countX)?
Do you want to define the class TestCreate?
etc.
 
KunwarAbhay Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Wouter: thanks for the advice.....I will try to embed the suggestion given by you into my code. But, is it possible to write into single file through multiple threads?


@John: Please find the modified code below:
[Example.java]

[TestFind.java]






Waiting for reply....as i m really stuck
 
KunwarAbhay Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Wouter : Variable [i,j,k] call methods create, authenticate and find of three different class....
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would rename them to something which clarifies their use. About the multiple threads accessing a single file: I doubt that is possible (in a simple way).
 
reply
    Bookmark Topic Watch Topic
  • New Topic