How to make one thread to wait for others in this situation?

i am simulating a 2 phase locking system (shared and exclusive locks). multiple clients connects and requests for lock to a single server. at the server end, we have a class Server which implements Runnable interface. for each connection, a new Server object is created and a new thread is started. when a conflicting lock request is made by a client, the corresponding thread in the server end must wait until other threads corresponding to clients holding the lock releases it. and when all the locks in conflicting mode are released, the thread releasing the last conflicting lock must notify the waiting thread.
but the wait() and notifyAll() methods are not working as desired. i guess this is because each thread is working on different Server objects.
how can i implement the waiting and notifying mechanism?

Let me recap your question: your Server is a single resource to which
multiple Clients want access in a CREW (Concurrent Read Exclusive Write)
fashion. You need a single object somewhere that can serve as the
single monitor for locking. A Singleton object like this should do it:public class CREW {
   private static CREW crew= new CREW();
   public static getCREW() { return crew; }
   private boolean wite;
   private int read;
   public synchronized acquireReadLock() {
      // your read locking stuff here
   public synchronized acquireWriteLock() {
      // your write locking stuff here
}... the important part is that there is a single object to lock on. The
'acquire...' methods can be pooped up at will (a Command as a
parameter mayhap?)
kind regards,
Jos

Similar Messages

  • How to make my object to wait for server response

    Hi ,
    I need some one suggestions on thread concepts.
    First Let me know my scenario is fit for thread concept.
    is it possible then how I can reach to solution.
    I have scenario like
    I send a request to server and server is taking some time to process the request.
    if I am calling the method on server it showing no results bez i know server takes some time.
    for that my calling method has to be wait for some time.
    Thanks
    Babu H

    Hi ,
    Let me give more information about that between my java class and server
    i have the bridge library which is also written in other than java.
    for that i used the njawin tool make as java wrapper class and accessing the java wrapper class(Bridge Server).
    the java wrapper class has post_request and poll_response methods so that why i 'm using only these methods in my java class to access the server.
    exactly I don't which technology is resided in Brdige server and actual Server bez that has been developed some one.
    poll_respnse means server has posted the response to client.
    Thanks
    Babu H

  • How to make the session to wait until other session get closed successfully

    Hi ,
    In my program , I am calling sql loader and after that I am opening a session and inside that I am calling stored procedure which validates the data.
    above calling of sql loader and stored procedure is done inside the shell script i.e .prog file which is registerd as host concurrent program.
    Here i am facing the problem like when two files are processed with same content then second file content's are not erroring out as duplicate though there is a duplicate validation exist inside the procedure. IF I call dbms_lock.sleep(60) then it is working and sencond file are records are error out with duplicate error message. but this is working only for small data files.
    Please suggest me how to make the session to come out successfully then only i can open other sesssion .
    Thanks
    Raghav

    user5853450 wrote:
    Hi ,
    In my program , I am calling sql loader and after that I am opening a session and inside that I am calling stored procedure which validates the data.
    above calling of sql loader and stored procedure is done inside the shell script i.e .prog file which is registerd as host concurrent program.
    Here i am facing the problem like when two files are processed with same content then second file content's are not erroring out as duplicate though there is a duplicate validation exist inside the procedure. IF I call dbms_lock.sleep(60) then it is working and sencond file are records are error out with duplicate error message. but this is working only for small data files.
    Please suggest me how to make the session to come out successfully then only i can open other sesssion .
    Thanks
    RaghavFor starters you could use external tables rather than SQL*Loader and then you could keep all the control on the database side of things rather than relying on an external utility. The external tables will give you all the functionality of SQL*Loader but all you to just read the data using SQL select statements instead and cut out all the shell script dependency.
    Alternatively you could also look at Job Chaining...
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14214/chapter1.htm#FEATURENO05574

  • How to make one album show up for multiple artists?

    I'd like some albums to show up under multiple artists in iTunes in Windows.  Say for example "The Basement Tapes" by Bob Dylan and The Band.  It would be nice to see this album under both these artists.  Or to have "Two Men With the Blues" show up under both Willie Nelson and Wynton Marsalis.  Can I do that with iTues?  If so I haven't figured out how.  It would be nice if using a delimiter such as as comma, slash of semi-colon would signify to iTunes that it should lists those songs under all artists but it doesn't.  At least commas didn't work.  Any help would be appreciated.

    iTunes doesn't have the ability to do what you want, i.e. to define multiple separated values in a field and then have the item show up when looking at a selection based on each of those values. "Bob Dylan", "The Band" and "Bob Dylan & The Band" are three distinct values that can't be linked together. Sort values can change where in a list things are displayed but shouldn't be used to attempt to merge different values as results are undefined and unpredictable.
    tt2

  • We have 3 locations coming up for our TV listings how do we make one the default and stop others?

    We have 3 locations coming up for our TV listings how do we make one the default and stop others?
    There is Bed Room, Living Room and Family how can we make ONLY FAMILY COME UP?
    When we check the listings or record from the TV Listing the LIVING ROOM comes up and only the Family has the controls to record.
    THANK YOU.
    Solved!
    Go to Solution.

    Please provide more details.
    What equipment do you have?
    Where do you see this listing? On STB? Online? Verizon App?
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.

  • Howto make created folders/ files from one teacher, read only for other teachers?

    Hello there,
    as an admin @ school I was wondering how to make created folders/ files from one teacher, read only for other teachers?
     - In a 2008domain, created a group "teachers"
     - created a folder "teacher data" where all teachers have read/write permissions
    ideal,a teacher who make's a folder in "teacher data" should be the only oen who is able to add file's to that folder and dele that folder or files. Other teachers may be able to read the content of the folder.
    Is this possible to set up and how?
    many thanks.
    Nico.
    rds

    Hi Nico,
    You could set the permissions below to resolve the issue:
    For the root folder "teacher data": give the full control permission to CREATOR OWNER – "Subfolders and files only" and give the read/write permissions to the group "teachers"– "This folder only".
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • How to make a Thread loop?

    Hi, I was wondering how to make a thread start over again from the beginning once it finishes, if it hasn't been stopped already.

    package src.Utility;
    public class ThreaTest extends Thread{
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              ThreaTest threaTest= new ThreaTest();
              while(true){
                   try{
                   if (!threaTest.isAlive()){
                        threaTest= new ThreaTest();
                        threaTest.start();
                   }//else{
                        //System.out.println("");
                   }catch (Exception e) {
                        e.printStackTrace();
         public void run(){
              System.out.println("-----11---------");
    }try the above code and then tell me if this loop works for you???

  • Can i make a method to wait for 2 mins before executing in java??

    can i make a method to wait for 2 mins before executing??
    i mean when i execute a method ....it has to wait for 2 mins before finally executing...
    can i do this in java????
    Thanks,

    Sure, put this at the beginning of the method.
    try
        Thread.sleep(120000);
    catch (Exception ex)

  • How to create one more server node for SAP J2EE server?

    Hi,
    Can any one please suggest how to create one more server node for SAP J2EE server? I am using WAS700.
    Thanks and Regards,
    Smriti.

    Hai,
          Login into the Configtool(C:\usr\sap\SID\DVEBMGS<inst no>\j2ee\configtool) if ABAP+JAVA stack or C:\usr\sap\SID\JC<inst no>\j2ee\configtool) if JAVA stack
    click on the instance and and select the addserver button on the top to create a servernode for J2EE server.
    Thanks and Regards,

  • I updated to ios7 on my iphone 4 and now cant install apps and one app says waiting for 2 days now. Also it started ading apps from my wife's phone onto my phone even though we have separate apple ids.

    I updated to ios7 on my iphone 4 and now cant install apps and one app says waiting for 2 days now. Also it started ading apps from my wife's phone onto my phone even though we have separate apple ids.

    We do not share an apple ID and her phone is now logged in with her account and I have since backed it up on itunes under her account as well. I have turned off automatic downloads on her phone but they still keep downloading. I delete one app and then another one just appears on the phone.

  • HT5796 I was on a a different Apple ID and I logged out because they didn't want me on there anymore so I figured out how to make one and now it's not letting me upgrade or download anything. I rebooted my iPhone 5, iOS 7.0.4 multiple times nothing fixed

    I was on a a different Apple ID and I logged out because they didn't want me on there anymore so I figured out how to make one and now it's not letting me upgrade or download anything. I rebooted my iPhone 5, iOS 7.0.4 multiple times nothing fixed my problem.

    I was on a a different Apple ID and I logged out because they didn't want me on there anymore so I figured out how to make one and now it's not letting me upgrade or download anything. I rebooted my iPhone 5, iOS 7.0.4 multiple times nothing fixed my problem.

  • Slide duration - How to make one slide have a different duration to another slide?

    Slide duration - How to make one slide have a different duration to another slide?
    EG So one slide has 2 seconds, another 4 another 6
    All I can see is how to make all slides have the same duration
    Any help very much appreciated!
    Brian

    Slide durations are not changeable on a slide-by-slide basis.

  • How to make Add to Favorites Option for website?

    Please Advice how to make Add to Favorites Option for the
    Website.
    Appreciated
    Thank You

    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=12&catid=189&threadid =1191543&highlight_key=y&keyword1=favorites

  • I downloaded CS6 and was told that it was possible to make a hard copy DVD for safety,is this correct and if so how is it done?.

    I downloaded CS6 and was told that it was possible to make a hard copy DVD for safety,is this correct and if so how is it done/.

    Use a DVD burning program:
    https://www.google.com/search?q=vdvd+burning+program&ie=utf-8&oe=utf-8&aq=t&rls=org.mozill a:en-US:official&client=firefo…

  • So... how long do we have to wait for a RAW update for the Nikon D600 camera?

    So... how long do we have to wait for a RAW update for the Nikon D600 camera?

    Adobe releases Camera Raw every 3 or 4 months. The D600 itself was launched only about 1 week ago. I'm sure its not included in ACR 7.2 RC yet. Nikon J1 is included though. I guess you're gona have to wait for it. Maybe 7.2 final release will have it or 7.3 should. Adobe employees/ product team will not commit to a time for Camera Raw releases.
    However, you can use the software Nikon would've given you to convert your images as TIFF and import them into Lightroom/ Photoshop if you're in a hurry. It would be nice if your camera supports DNG conversion out of the box! This way, you wont need a Camera Raw from Adobe.
    Anyway, you could file a 'Feature Request' to Adobe here: https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    Good luck.

Maybe you are looking for

  • Copying SSL Certificates from one server to another.

    I have a question that hopefully someone might have the answer for... I have a IPlanet 6.0 SP4 server that has an SSL certificate I'm trying to move to a new server that's on SunOne 6.1. I was under the impression that I could easily copy the <Iplane

  • Error Handling and Error Messages

    I already posted this in the java programming forum, but I dont think the people responded understand patterns, or what I was asking. Here is my original post, for reference I am not asking how to catch and exception, or how to display an error, I am

  • Invalid Column Name message in the subquery

    Hi All, I am receiving the invalid column name message in the subquery. Please help me if there is any work around or change in the query: Sample query: update table1 set table1.column1 = (Select column1 from (Select column1 from table2 where table1.

  • FSG - How to define a 'static' period

    hello: we are using Oracle Financials FSG and i need to setup a column set that has 12 STATIC months - for each month of our fiscal year. that way we can do comparisons to the same month in the prior fiscal year. in other words, i want to define "Jan

  • Dynamic Documents missing plugin

    Hello, I tried to open an InCopy today and recieved an error that I was missing a plugin called "Dynamic Documents.InDesignPlugin." I checked in my plugin folder and sure enough it was still in the "Graphics" folder. What does this plugin control? Is