Menu

multithreading

Help
mattlf
2008-09-22
2013-04-22
  • mattlf

    mattlf - 2008-09-22

    Hi

    If i want to subscribe to receive streaming for multiple stocks, i do the following

    TickStreamCommand command = new TickStreamCommand();
    command.setExchangeCode("Q");
    command.setSymbolCode("MSFT");
    .....
    IRequest request = connection.prepareRequest(command);
    request.submit();

    does it create a separate thread for each stock ? Or Is there some multiplex mechanism underneath

    Thank you for your answer

     
    • Mike Kroutikov

      Mike Kroutikov - 2008-09-22

      Hi,

      submit as many requests as you wish (use one connection). No, it does not create a separate thread for every stock. There is a single "event dispatching" thread that will be calling delegates methods - so you do not need to synchronize them - responses to different requests will arrive serially.

      Internally, there are three threads there in addition to the "main" thread (you have exposure to one of them - the event dispatching thread, other two threads are internal: "writer" thread that sends data to the OT server, and "reader" thread that reads data).

      -Mike

       

Log in to post a comment.

MongoDB Logo MongoDB