• Post Reply Bookmark Topic Watch Topic
  • New Topic

Observables  RSS feed

 
fahad siddiqui
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Observables are not threads rite? they get invoked sequentially and there do any further processing also sequentially, not parallely.
Am i right on this?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct, Observables are not threads, and they do not create any new threads. When notifyObservers() is called, the Observable calls update() for each Observer in the same thread that was used to call notifyObservers(), sequentially. There may still be other things happening in parallel if your program is already using multiple threads. An Observer can function in a multi-threaded environment, but it does not create any new threads itself.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... but it does not create any new threads itself.


Well, it can start a new thread if it wants to. It's not automatic or built in by any means but it is a good thing in some situations to move the reaction to the event to another thread.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!