• 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

bulk syncing of data

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Hi All

I am working on the j2me appln.The appln syncs data to the server depending on the dates which is selected and this data is saved in the rms files.

Currently my requirement is that, the application should syncs all the saved data on click of one command and also the data should be synced sequentially.

For ex : I am syncing the data of 18,19,20 and 21. Now I want that until and unless the server sends an acknowledgement for 18 th the 19th should not be uploaded.
By this I mean t5hat,19th thread should be kept on hold until and unless I receive the ack for 18 thread from server


thanks
Suraj
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are several options I can think of:

You could wait for the threads to reach each other at the same point before proceeding to the network connection, checking their progress with some volatile booleans.

It sounds like a buffer might be useful, something to hold the data as it completes, perhaps a Hashtable or a custom wrapper object, so you can organize it.

There are sleep() and join() methods in the Thread class. These might help if you don't mind blocking a thread for a while or ending it. Otherwise, if you intend to continue using these threads afterwards, these Thread methods probably won't help.

You can declare a method synchronized to run a method one thread at a time, but this blocking is slow, or you could use a synchronized block, with a locking reference using a private object reference or perhaps the current object's lock (this keyword), within a method to atomically block just a small section of method which allows other threads to run between the lines before/after the non-synchronized calls.
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic