Results 1 to 5 of 5
  1. #1
    sbutt is offline Banned
    Join Date
    Apr 2009
    Posts
    22
    Rep Power
    0

    Default multiple user requests accessing the same file - deadlock?

    ----
    Last edited by sbutt; 02-19-2015 at 01:03 PM.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: multiple user requests accessing the same file - deadlock?

    There won't be anything like a deadlock, but what will happen is very operating system dependent. On Windows it will error out with an exception when you open the same file for writing multiple times.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    sbutt is offline Banned
    Join Date
    Apr 2009
    Posts
    22
    Rep Power
    0

    Default Re: multiple user requests accessing the same file - deadlock?

    ----
    Last edited by sbutt; 02-19-2015 at 01:03 PM.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: multiple user requests accessing the same file - deadlock?

    Many OSes impose a WORM (Write Once, Read Multiple) restriction on file access; better use a lock object on which the several threads can synchronize for the file access. The lock object server as the shared resource.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: multiple user requests accessing the same file - deadlock?

    What Jos says (basically I would say program defensively and assume the worst will happen, which in this case is to synchronize access to prevent any concurrent access at all)

    But:

    Quote Originally Posted by sbutt View Post
    what if we have file.close() in the finally block?
    Can you explain not only to me but also to yourself why you think that has any baring on anything at all?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 9
    Last Post: 09-05-2013, 05:56 PM
  2. Multiple Requests on Servlet Errored
    By ksur12345 in forum Java Servlet
    Replies: 8
    Last Post: 08-11-2011, 09:17 AM
  3. Accessing multiple database
    By saurabh1989 in forum JDBC
    Replies: 0
    Last Post: 02-23-2011, 05:04 PM
  4. Replies: 3
    Last Post: 01-14-2010, 04:22 AM
  5. Replies: 12
    Last Post: 11-05-2009, 07:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •