Android: How to implement “distributed control”

前端 未结 2 588
一向
一向 2021-02-10 14:39

{Apologies for the cross-post with android-developers forum. Haven\'t received any answers there}

I have an interesting design challenge:

I have a fro

2条回答
  •  无人及你
    2021-02-10 15:10

    How about using a blocking queue, because your description reminds me of a the classic producer-consumer problem from parallel programming class.

    http://en.wikipedia.org/wiki/Producer-consumer_problem

    Also Java 1.5 seems to have an implementation of the blocking-queue, I can't recall off the top of my head if its available on Android.

    http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/BlockingQueue.html

    I'd imagine you can setup 2 uni-directional blocking queue's for communication each way. Q1 would have front-end as producer and back-end as consumer. Q2 would have front-end as consumer and back-end as producer.

    Also you could use the "Command" design pattern for the communication 'messages'.

    http://en.wikipedia.org/wiki/Command_pattern

    HTH

提交回复
热议问题