<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Android Popping Bubbles Example</title>
	<atom:link href="http://stuffthathappens.com/blog/2009/03/31/android-popping-bubbles/feed/" rel="self" type="application/rss+xml" />
	<link>http://stuffthathappens.com/blog/2009/03/31/android-popping-bubbles/</link>
	<description>Technology and Geek Stuff by Eric Burke</description>
	<lastBuildDate>Thu, 04 Nov 2010 22:37:00 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Manoj Mathew</title>
		<link>http://stuffthathappens.com/blog/2009/03/31/android-popping-bubbles/comment-page-1/#comment-32809</link>
		<dc:creator>Manoj Mathew</dc:creator>
		<pubDate>Wed, 01 Apr 2009 10:23:42 +0000</pubDate>
		<guid isPermaLink="false">http://stuffthathappens.com/blog/?p=1114#comment-32809</guid>
		<description>I am not an Android guy but let me put some comments regarding the synchronization that you added in the model object.

I guess you can completely remove the synchronization of model&#039;s collection object by using another trick. If I understood correctly, following is the code snippet that demands the need for synchronization on model&#039;s bubble collection. 

 if (event.getAction() == MotionEvent.ACTION_DOWN) {
      model.addBubble(event.getX(), event.getY());
      return true;
   }

Instead of adding bubble in the async: onTouch callback, add the eventX and eventY to a synchronized eventqueue. Then poll and clear this queue and subsequently add bubbles in the gameloop. In this way, we can safely remove all the synchronization that you put in the model class. Sync is still there but only for the eventqueue. We access them only in a serial fashion with in the gameloop. 

Try to do such a serial access to MediaPlayer also. 

Basic idea is simple. Stay away from concurrent modification to shared data structure but store the callback related events and access them in a serial way in the gameloop. Its little bit tricky but I have successfully applied for j2me.</description>
		<content:encoded><![CDATA[<p>I am not an Android guy but let me put some comments regarding the synchronization that you added in the model object.</p>
<p>I guess you can completely remove the synchronization of model&#8217;s collection object by using another trick. If I understood correctly, following is the code snippet that demands the need for synchronization on model&#8217;s bubble collection. </p>
<p> if (event.getAction() == MotionEvent.ACTION_DOWN) {<br />
      model.addBubble(event.getX(), event.getY());<br />
      return true;<br />
   }</p>
<p>Instead of adding bubble in the async: onTouch callback, add the eventX and eventY to a synchronized eventqueue. Then poll and clear this queue and subsequently add bubbles in the gameloop. In this way, we can safely remove all the synchronization that you put in the model class. Sync is still there but only for the eventqueue. We access them only in a serial fashion with in the gameloop. </p>
<p>Try to do such a serial access to MediaPlayer also. </p>
<p>Basic idea is simple. Stay away from concurrent modification to shared data structure but store the callback related events and access them in a serial way in the gameloop. Its little bit tricky but I have successfully applied for j2me.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.214 seconds -->

