Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:09:01+00:00 2026-06-08T08:09:01+00:00

// multiple server instances (replicas), coordinated using MsgCoordinationService public class Server { ConcurrentHashMap<TxID,Future<Msg>> local_registry

  • 0
// multiple server instances (replicas), coordinated using MsgCoordinationService
public class Server {

    ConcurrentHashMap<TxID,Future<Msg>> local_registry = new ...
    MsgCoordinationService coordination_service = new .. 

    ...

    // Socket instance to communicate with a client...
    public void accept(Socket s) {
        new Thread(new Worker(s)).start();
    }

    // propose msg to coordination service, register demand to respond to client in local registry
    public Future<Msg> register(Msg m) {
        FutureMsg f = new MsgFuture(); // Future handle w. reference to an empty Msg object [= response]
        TxID uniqueID = coordination_service.propose(s); // transaction ID
        local_registry.add(uniqueID, f);
        return f;
    }

    // called by coordination service, guaranteeing a global order on msg deliveries
    public synchronized void deliver(TxID id, Msg m) {
        ... process Msg object [request]
        ... if local_registry.contains(id), 'compile' response
            (using the Msg object from FutureMsg f, f.get() - f.isDone() when a certain Msg flag has been set)

        ___ now:
        ... notify waiting 'Worker' threads to check whether their 'Future' object isDone()
    }

    private class Worker implements Runnable {
        ...
        public void run() {
            ...
            Future<Msg> f = Server.this.register(request); // obtained through Socket s

            while(!f.isDone())
                wait();

            response = f.get();
            ...
        }
    }
}

I’m implementing a replicated service [multiple servers, clients communicate w. a single server instance, create/update/delete operations will be distributed by means of a coordination service that guarantees a global order on message deliveries].

Once a client establishes a new connection to a server instance, all communication is channeled through a dedicated Worker instance [that processes read requests locally, and broadcasts C/U/D operations using Server.this.register(...)].

register itself basically records requests for future local processing/reply – and forwards a Msg object to the coordination service.

The service redelivers the Msg object via deliver, …and after processing the encapsulated task, the Worker instance which originally received the client request shall be notified to hand over the corresponding response.

For certain reasons, my design seems to be broken… – w/o synchronized(this) [in Worker#run()], wait() won’t wait; with synchronized(this), a notifyAll() in Server#deliver(...) won’t release the lock on the “blocked” Worker instance.

Long story short: as it turns out, I need you help… either (a): to understand the very basics of wait/notify/notifyAll or (b): to improve my design …or (c): (a) and (b).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:09:03+00:00Added an answer on June 8, 2026 at 8:09 am

    A thread calling wait/notify requires the lock on the object on which these methods are called, otherwise you will get an exception. In the general form, assuming an arbitrary object:

    final Object obj = new Object();
    ...
    
    synchronized(obj) {
        while(/* condition */) {
           obj.wait();
        }
    }
    

    The reason why your wait is not being released by the notify is that you are doing a this.wait() inside a different object than the one where you are calling notify, hence they are not paired. You need to use the same instance for both calls. You are doing this.wait() inside an instance of Worker and doing this.notifyAll() inside an instance of Server, so this does not refer to the same object.

    You should create a single synchronization object visible across classes and threads and synchronize on that one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run multiple instances of a node server using a bash script.
I am using a POJO (Non-EJB) class inside my JBoss server and creating multiple
I am creating a custom ASP.NET AJAX server control in which multiple instances of
SQL Server 2005 x64 on Windows Server 2003 x64, with multiple instances (default +
I need to run multiple(more than 4) instances of JBoss server on a single
I have a simple python server script which forks off multiple instances (say N)
I am using the code below to download multiple attachments from a TFS server:
I have installed AppFabric on server and I want multiple instances to point to
If we have multiple sql server instances in a computer, how can we know
Using the Microsoft.Samples.ReportingServices.ReportViewer, I am showing multiple instances of the same SRS report on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.