davidfoerster / KaleidOK-examples

KaleidOk invites participants to use a new kind of interactive media tool and take part in an emerging experience which explores speech recognition, media retrieval and visuals generating in a collaborative context (between people, and between people and machines).
http://www.kaleidok.co/
5 stars 0 forks source link

Thread for every image result #11

Closed davidfoerster closed 9 years ago

davidfoerster commented 9 years ago

From @Disastergirl on May 26, 2015 11:37

Threading is needed to continue the animation while the requests for data continue to run. Create a bunch of "worker threads" and have those worker threads go through a common job queue.

Copied from original issue: Disastergirl/Kaleidoscope#5

davidfoerster commented 9 years ago

I agree, that some tasks should be loaded off to worker threads, in particular long input/output operations like network requests (e. g. search requests and resource/image downloads) and later some computational tasks (e. g. speech transcription or other complex audio analyses). An alternative for I/O would be an event handler loop waiting for termination of those operations and dispatching their results (reactor pattern).

The current event handling is a sham, because long, blocking (network) operations run synchronously in the event dispatcher thread of the user interface, stalling/freezing it in the mean time.

This requires some sort of synchronisation between concurrent threads, of course, and your recommendations go into the right direction, but you seem to be unaware, that Java provides

  1. the synchronize keyword to denote critical sections handled and enforced by the runtime environment and
  2. container classes, that pretty much synchronise themselves based on the above critical sections and that should be used instead of arrays for concurrent access.
Disastergirl commented 9 years ago

I am unaware of what Java provides. But I emphasise that working on this is vital for user experience.

davidfoerster commented 9 years ago

Implemented as of 6212ddb7841e0eef40b5516b3f4da6e8047b94c6.