Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Synchronizing IO Streams  RSS feed

 
vignesh bala
Greenhorn
Posts: 28
Eclipse IDE Hibernate Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I need some suggesstions on a problem. I am using two programs operating on same file. The two programs are seperate.My need is , when one program is reading from the file, another must not write in it(simultaneous access). I can't use the synchronized blocks here because the two are seperate programs and doesnot share any objects.Can anybody suggest some way to do this.
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at This post.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At a high level you might use something that both programs can lock on, a third entity of some kind. I smiled at the server socket idea in the other thread ... you can only write if you can open a server socket on port x. A database or a third program might do the same job.

Or you could use a queue that both programs can write to that manages itself to only execute one queued write request at a time. That could be a third program again, or one of the pair. Program A would do all the writing, program B would use some kind of inter-process thing, eg sockets, to send write requests to A.

Or just hang a necktie on the door knob.
 
vignesh bala
Greenhorn
Posts: 28
Eclipse IDE Hibernate Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry guys,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!