<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Últimas mensagens do tópico "Processamento Paralelo em Scala"]]></title>
		<link>http://www.guj.com.br/posts/list/20.java</link>
		<description><![CDATA[Últimas mensagens enviadas no tópico "Processamento Paralelo em Scala"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Processamento Paralelo em Scala</title>
				<description><![CDATA[ Olá:<br /> <br /> Estou experimentando usar Programação Paralela em Scala. Baseado neste [url=http://stackoverflow.com/questions/1751953/concurrent-map-foreach-in-scala]exemplo do site StackOverflow[/url], criei um programa baseado no [url=http://projecteuler.net/index.php?section=problems&id=1]Problema 1 do Project Euler[/url]. Experimentei três modos: O primeiro é uma execução simples, sem paralelismo. O segundo usando a API do java.util.concurrency, através de [url=http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html]Executors[/url] e [url=http://java.sun.com/javase/6/docs/api/java/util/concurrent/Callable.html]Callables[/url]. O Terceiro, baseado na sugestão da página do StackOverflow, usando [url=http://www.scala-lang.org/docu/files/api/scala/actors/Futures$object.html]scala.Futures[/url]. O objetivo é comparar os tempos de se percorrer o range paralelamente e executar a soma.<br /> Segue-se o código:<br /> [code]<br /> package sandbox<br /> <br /> import java.util.concurrent._<br /> import scala.actors._<br /> <br /> object TestPool {<br />   <br />   def eval(n: Int): Boolean = (n % 3 == 0) || (n % 5 == 0)<br />   <br />   def runSingle(max: Int): Int = (1 until max).filter(eval(_)).foldLeft(0)(_ + _)<br />   <br />   def runPool(max: Int): Int = {<br />     <br />     def getCallable(i: Int): Callable[Boolean] = new Callable[Boolean] { def call = eval(i) }<br />     <br />     val pool = Executors.newFixedThreadPool(5)<br />     val result = (1 until max).filter(i =&gt; pool.submit(getCallable(i)).get).foldLeft(0)(_ + _)<br />     pool.shutdown<br />     pool.awaitTermination(Math.MAX_LONG, TimeUnit.SECONDS)<br />     <br />     result<br />   }<br />   <br />   def runFutures(max: Int): Int = (1 until max).filter(i =&gt; Futures.future(eval(i)).apply).foldLeft(0)(_ + _)<br />   <br />   /**<br />    * f é a função a ser executada. O retorno é uma Tuple2 contendo a soma e o <br />    * tempo de execução.<br />    */<br />   def test(max: Int, f: Int =&gt; Int): (Int, Long) = {<br />     val t0 = System.currentTimeMillis<br />     val result = f(max)<br />     val deltaT = System.currentTimeMillis - t0<br />     <br />     (result, deltaT)<br />   }<br />   <br />   <br />   def main(args : Array[String]) : Unit = {<br />     val max = 10000<br />     <br />     println("Single : " + test(max, runSingle))<br />     println("Pool   : " + test(max, runPool))<br />     println("Futures: " + test(max, runFutures))<br />   }<br /> }<br /> [/code]<br /> O resultados que obtive foram os seguntes:<br /> - max = 10:<br /> [quote]<br /> Single : (23,31)<br /> Pool   : (23,16)<br /> Futures: (23,31)<br /> [/quote]<br /> - max = 100:<br /> [quote]<br /> Single : (2318,33)<br /> Pool   : (2318,31)<br /> Futures: (2318,55)<br /> [/quote]<br /> - max = 1000:<br /> [quote]<br /> Single : (233168,42)<br /> Pool   : (233168,111)<br /> Futures: (233168,364)<br /> [/quote]<br /> - max = 10000:<br /> [quote]<br /> Single : (23331668,144)<br /> Pool   : (23331668,544)<br /> Futures: ... demorou muito e cancelei a execução<br /> [/quote]<br /> Claramente usando as APis de concorrencia do Java e de Scala não está gerando os resultados esperados. Portanto eu pergunto: Onde estou errando? Qual seria a forma mais adequada de se utilizar a Concorrência? E quanto aos atores de Scala? Como eles poderiam ser utilizados?<br /> <br /> Grato,]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197163/989055/processamento-paralelo-em-scala
</guid>
				<link>http://www.guj.com.br/prepost/197163/989055/processamento-paralelo-em-scala
</link>
				<pubDate><![CDATA[Tue, 2 Feb 2010 23:08:53]]> GMT</pubDate>
				<author><![CDATA[ Rafael Afonso]]></author>
			</item>
			<item>
				<title>Processamento Paralelo em Scala</title>
				<description><![CDATA[ O resultado que vc esperava era qual? uma solução ser mais rápida que a outra?<br /> <br /> Acho que vc esta confundindo programação concorrente (que é a execução por diferentes threads) com paralelismo (execução em paralelo para fins de performance).<br /> <br /> Scala não é capaz de explorar paralelismo de threads automaticamente. Alias, não conheco nenhuma linguagem que faça isso. Geralmente essa é uma decisão que fica a critério do programador, e o papel da linguagem é fornecer uma API que seja capaz de tirar proveito desse recurso. Em clojure por exemplo, existe uma variante da função map que é capaz de explorar paralelismo, veja [url=http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/pmap]pmap[/url]/[url=http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/pcalls]pcalls[/url]. Em Scala não sei como funciona, sugiro que de uma olhada na documentação da linguagem.<br /> <br /> O motivo pela qual a solução que usa pool de threads é pouca coisa mais rapida que as demais é porque, apesar de existirem 5 threads, elas não ajudam em quase nada já que comparado aos resto da computação que é feita, executar a expressão (n % 3 == 0) || (n % 5 == 0) é praticamente irrelevante, como mostrado pelos resultados obtidos. Passe o filtro para ser executado pela thread usando pool.invokeAll ao inves de pool.submit, que provavelmente o desempenho ira melhorar.<br /> <br /> Sobre Futures, isso não tem nada a ver com paralelismo, é apenas uma forma de programação assincrona.<br /> <br /> Atores é um modelo para computação distrubuida, não vejo como poderia ser usada para paralelismo local.]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197163/989296/processamento-paralelo-em-scala
</guid>
				<link>http://www.guj.com.br/prepost/197163/989296/processamento-paralelo-em-scala
</link>
				<pubDate><![CDATA[Wed, 3 Feb 2010 10:34:18]]> GMT</pubDate>
				<author><![CDATA[ mochuara]]></author>
			</item>
			<item>
				<title>Re:Processamento Paralelo em Scala</title>
				<description><![CDATA[ Olá:<br /> <br /> Desculpe a demora, mas aí vai a minha resposta. Em primeiro lugar nunca lidei de verdade com multiprocessamento (vide a confusão que você apontou), de forma que parece ainda terei que ralar mais. Além disso ainda não consegui entender o esquema dos Actors de Scala. De qualquer forma, experimentei utilizar ExecutorSevice/Callables e também Actors conforme me foi sugerido [url=http://groups.google.com/group/scala-br/browse_thread/thread/0b81d407233fb316/9e7dd4a683370210#9e7dd4a683370210]aqui[/url].<br /> [code]<br /> package sandbox<br /> <br /> import java.util.concurrent._<br /> import scala.actors._<br /> <br /> object TestPool {<br />   <br />   def eval(n: Int): Boolean = (n % 3 == 0) || (n % 5 == 0)<br />   <br />   def closePool(pool: ExecutorService) {<br />     pool.shutdown<br />     pool.awaitTermination(Math.MAX_LONG, TimeUnit.SECONDS)<br />   }<br />   <br />   def runSingle(max: Int): Long = (1 until max).filter(eval(_)).foldLeft(0L)(_ + _)<br />   <br />   def runPool(max: Int): Long = {<br />     <br />     def getCallable(i: Int): Callable[Boolean] = new Callable[Boolean] { def call = eval(i) }<br />     <br />     val pool = Executors.newCachedThreadPool <br />     val result = (1 until max).filter(i =&gt; pool.submit(getCallable(i)).get).foldLeft(0L)(_ + _)<br />     closePool(pool)<br />     <br />     result<br />   }<br />   <br />   def runPoolJava(max: Int): Long = {<br />     var sum = 0L<br />     <br />     class SumCallable(n: Int) extends Callable[Int] {<br />       def call = {<br />         if(eval(n)) sum += n<br />         n<br />       }<br />     }<br />     <br />     val callables: java.util.List[Callable[Int]] = new java.util.ArrayList[Callable[Int]](max + 1)<br />     (1 until max).foreach(i =&gt; callables.add(new SumCallable(i)))<br />     <br />     val pool = Executors.newCachedThreadPool <br />     pool.invokeAll(callables)<br />     closePool(pool)<br />     <br />     sum<br />   }<br />   <br />   def runActors(max: Int): Long = {<br />     import scala.actors.Actor._<br />     <br />     case class Add(n: Int)<br />     <br />     case object Result<br />     <br />     val act = actor {<br />       var sum = 0L<br />       loop {<br />         react {<br />           case Add(n) =&gt; if (eval(n)) { sum += n }<br />           case Result =&gt; reply(sum); exit<br />         }<br />       }<br />     }<br />    <br />     for (i &lt;- 1 until max) act ! Add(i)<br />    <br />     act !? Result match {<br />       case result =&gt; result.toString.toLong<br />     }<br />   }<br /> <br />   <br />   /**<br />    * f é a função a ser executada. O retorno é uma Tuple2 contendo a soma e o <br />    * tempo de execução.<br />    */<br />   def test(max: Int, f: Int =&gt; Long): (Long, Long) = {<br />     val t0 = System.currentTimeMillis<br />     val result = f(max)<br />     val deltaT = System.currentTimeMillis - t0<br />     <br />     (result, deltaT)<br />   }<br />   <br />   def testMax(max: Int) {<br />     println("* Max = " + max)<br />     println("Single  : " + test(max, runSingle))<br />     println("Pool    : " + test(max, runPool))<br />     println("PoolJava: " + test(max, runPoolJava))<br />     println("Actors  : " + test(max, runActors))<br />     println<br />   }<br />   <br />   def main(args : Array[String]) : Unit = {<br />     Array(0, 1, 3, 10, 30, 100, 300, 1000, 3000, 10000, 30000, 100000).foreach(testMax(_))<br />   }<br /> }<br /> [/code]<br /> Os resultados, infelizmente não foram muito melhores. E Além disso, no caso de PoolJava (ExecutorSevice/Callables) o resultado tornou-se errado a partir para 10000 e 100000.<br /> <br /> * Max = 0<br /> Single  : (0,14)<br /> Pool    : (0,169)<br /> PoolJava: (0,2)<br /> Actors  : (0,170)<br /> <br /> * Max = 1<br /> Single  : (0,0)<br /> Pool    : (0,0)<br /> PoolJava: (0,0)<br /> Actors  : (0,15)<br /> <br /> * Max = 3<br /> Single  : (0,1)<br /> Pool    : (0,19)<br /> PoolJava: (0,4)<br /> Actors  : (0,8)<br /> <br /> * Max = 10<br /> Single  : (23,0)<br /> Pool    : (23,6)<br /> PoolJava: (23,16)<br /> Actors  : (23,19)<br /> <br /> * Max = 30<br /> Single  : (195,2)<br /> Pool    : (195,11)<br /> PoolJava: (195,10)<br /> Actors  : (195,19)<br /> <br /> * Max = 100<br /> Single  : (2318,1)<br /> Pool    : (2318,3)<br /> PoolJava: (2318,8)<br /> Actors  : (2318,8)<br /> <br /> * Max = 300<br /> Single  : (20850,2)<br /> Pool    : (20850,45)<br /> PoolJava: (20850,29)<br /> Actors  : (20850,19)<br /> <br /> * Max = 1000<br /> Single  : (233168,8)<br /> Pool    : (233168,71)<br /> PoolJava: (233168,98)<br /> Actors  : (233168,122)<br /> <br /> * Max = 3000<br /> Single  : (2098500,33)<br /> Pool    : (2098500,203)<br /> PoolJava: (2098500,147)<br /> Actors  : (2098500,216)<br /> <br /> * Max = 10000<br /> Single  : (23331668,48)<br /> Pool    : (23331668,189)<br /> PoolJava: (23323633,355)<br /> Actors  : (23331668,417)<br /> <br /> * Max = 30000<br /> Single  : (209985000,62)<br /> Pool    : (209985000,170)<br /> PoolJava: (209985000,425)<br /> Actors  : (209985000,138)<br /> <br /> * Max = 100000<br /> Single  : (2333316668,12)<br /> Pool    : (2333316668,518)<br /> PoolJava: (2333253053,1103)<br /> Actors  : (2333316668,315)<br /> <br /> Pelo visto ainda há muito o que aprender nesta área. <br /> Mas vou seguir sua sugestão e tentar com algo que exija mais mais processamento, como verificar quais números de 0 até N são primos por exemplo.<br /> <br /> Grato, <br /> <br /> ]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197163/990658/reprocessamento-paralelo-em-scala
</guid>
				<link>http://www.guj.com.br/prepost/197163/990658/reprocessamento-paralelo-em-scala
</link>
				<pubDate><![CDATA[Thu, 4 Feb 2010 22:19:38]]> GMT</pubDate>
				<author><![CDATA[ Rafael Afonso]]></author>
			</item>
			<item>
				<title>Re:Processamento Paralelo em Scala</title>
				<description><![CDATA[ Já tentou erlang?  <img src="http://www.guj.com.br/images/smilies/8a80c6485cd926be453217d59a84a888.gif" border="0"> <br /> Agora, se quiser ficar no mundo java, tem esse projeto aqui [url]http://akkasource.org/[/url]<br /> Ela está na minha study list faz um tempo já.]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197163/990661/reprocessamento-paralelo-em-scala
</guid>
				<link>http://www.guj.com.br/prepost/197163/990661/reprocessamento-paralelo-em-scala
</link>
				<pubDate><![CDATA[Thu, 4 Feb 2010 22:28:16]]> GMT</pubDate>
				<author><![CDATA[ fabiofalci]]></author>
			</item>
			<item>
				<title>Re:Processamento Paralelo em Scala</title>
				<description><![CDATA[ [quote=fabiofalci]Já tentou erlang?  <img src="http://www.guj.com.br/images/smilies/8a80c6485cd926be453217d59a84a888.gif" border="0"> <br /> Agora, se quiser ficar no mundo java, tem esse projeto aqui [url]http://akkasource.org/[/url]<br /> Ela está na minha study list faz um tempo já.[/quote]<br /> Oi! Erlang talvez para mais tarde...<br /> Quanto ao Akka já visto referências a ele em alguns feeds sobre Scala mas nunca prestei muita atenção. Agora vou ler o artigo sobre [url=http://en.wikipedia.org/wiki/Actor_model]Actors na Wikipedia[/url] e também dois artigos do Martin Odersky (criador do Scala para quem não sabe) a respeito do assunto ([url=http://lampwww.epfl.ch/~odersky/papers/jmlc06.pdf]aqui[/url] e [url=http://lamp.epfl.ch/~phaller/doc/haller07coord.pdf]aqui[/url]).<br /> <br /> Grato, ]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197163/990668/reprocessamento-paralelo-em-scala
</guid>
				<link>http://www.guj.com.br/prepost/197163/990668/reprocessamento-paralelo-em-scala
</link>
				<pubDate><![CDATA[Thu, 4 Feb 2010 22:39:35]]> GMT</pubDate>
				<author><![CDATA[ Rafael Afonso]]></author>
			</item>
			<item>
				<title>Re:Processamento Paralelo em Scala</title>
				<description><![CDATA[ [quote=Rafael Afonso]Olá:<br /> <br /> Desculpe a demora, mas aí vai a minha resposta. Em primeiro lugar nunca lidei de verdade com multiprocessamento (vide a confusão que você apontou), de forma que parece ainda terei que ralar mais. Além disso ainda não consegui entender o esquema dos Actors de Scala. De qualquer forma, experimentei utilizar ExecutorSevice/Callables e também Actors conforme me foi sugerido [url=http://groups.google.com/group/scala-br/browse_thread/thread/0b81d407233fb316/9e7dd4a683370210#9e7dd4a683370210]aqui[/url].<br /> [code]<br /> package sandbox<br /> <br /> import java.util.concurrent._<br /> import scala.actors._<br /> <br /> object TestPool {<br />   <br />   def eval(n: Int): Boolean = (n % 3 == 0) || (n % 5 == 0)<br />   <br />   def closePool(pool: ExecutorService) {<br />     pool.shutdown<br />     pool.awaitTermination(Math.MAX_LONG, TimeUnit.SECONDS)<br />   }<br />   <br />   def runSingle(max: Int): Long = (1 until max).filter(eval(_)).foldLeft(0L)(_ + _)<br />   <br />   def runPool(max: Int): Long = {<br />     <br />     def getCallable(i: Int): Callable[Boolean] = new Callable[Boolean] { def call = eval(i) }<br />     <br />     val pool = Executors.newCachedThreadPool <br />     val result = (1 until max).filter(i =&gt; pool.submit(getCallable(i)).get).foldLeft(0L)(_ + _)<br />     closePool(pool)<br />     <br />     result<br />   }<br />   <br />   def runPoolJava(max: Int): Long = {<br />     var sum = 0L<br />     <br />     class SumCallable(n: Int) extends Callable[Int] {<br />       def call = {<br />         if(eval(n)) sum += n<br />         n<br />       }<br />     }<br />     <br />     val callables: java.util.List[Callable[Int]] = new java.util.ArrayList[Callable[Int]](max + 1)<br />     (1 until max).foreach(i =&gt; callables.add(new SumCallable(i)))<br />     <br />     val pool = Executors.newCachedThreadPool <br />     pool.invokeAll(callables)<br />     closePool(pool)<br />     <br />     sum<br />   }<br />   <br />   def runActors(max: Int): Long = {<br />     import scala.actors.Actor._<br />     <br />     case class Add(n: Int)<br />     <br />     case object Result<br />     <br />     val act = actor {<br />       var sum = 0L<br />       loop {<br />         react {<br />           case Add(n) =&gt; if (eval(n)) { sum += n }<br />           case Result =&gt; reply(sum); exit<br />         }<br />       }<br />     }<br />    <br />     for (i &lt;- 1 until max) act ! Add(i)<br />    <br />     act !? Result match {<br />       case result =&gt; result.toString.toLong<br />     }<br />   }<br /> <br />   <br />   /**<br />    * f é a função a ser executada. O retorno é uma Tuple2 contendo a soma e o <br />    * tempo de execução.<br />    */<br />   def test(max: Int, f: Int =&gt; Long): (Long, Long) = {<br />     val t0 = System.currentTimeMillis<br />     val result = f(max)<br />     val deltaT = System.currentTimeMillis - t0<br />     <br />     (result, deltaT)<br />   }<br />   <br />   def testMax(max: Int) {<br />     println("* Max = " + max)<br />     println("Single  : " + test(max, runSingle))<br />     println("Pool    : " + test(max, runPool))<br />     println("PoolJava: " + test(max, runPoolJava))<br />     println("Actors  : " + test(max, runActors))<br />     println<br />   }<br />   <br />   def main(args : Array[String]) : Unit = {<br />     Array(0, 1, 3, 10, 30, 100, 300, 1000, 3000, 10000, 30000, 100000).foreach(testMax(_))<br />   }<br /> }<br /> [/code]<br /> Os resultados, infelizmente não foram muito melhores. E Além disso, no caso de PoolJava (ExecutorSevice/Callables) o resultado tornou-se errado a partir para 10000 e 100000.<br /> <br /> * Max = 0<br /> Single  : (0,14)<br /> Pool    : (0,169)<br /> PoolJava: (0,2)<br /> Actors  : (0,170)<br /> <br /> * Max = 1<br /> Single  : (0,0)<br /> Pool    : (0,0)<br /> PoolJava: (0,0)<br /> Actors  : (0,15)<br /> <br /> * Max = 3<br /> Single  : (0,1)<br /> Pool    : (0,19)<br /> PoolJava: (0,4)<br /> Actors  : (0,8)<br /> <br /> * Max = 10<br /> Single  : (23,0)<br /> Pool    : (23,6)<br /> PoolJava: (23,16)<br /> Actors  : (23,19)<br /> <br /> * Max = 30<br /> Single  : (195,2)<br /> Pool    : (195,11)<br /> PoolJava: (195,10)<br /> Actors  : (195,19)<br /> <br /> * Max = 100<br /> Single  : (2318,1)<br /> Pool    : (2318,3)<br /> PoolJava: (2318,8)<br /> Actors  : (2318,8)<br /> <br /> * Max = 300<br /> Single  : (20850,2)<br /> Pool    : (20850,45)<br /> PoolJava: (20850,29)<br /> Actors  : (20850,19)<br /> <br /> * Max = 1000<br /> Single  : (233168,8)<br /> Pool    : (233168,71)<br /> PoolJava: (233168,98)<br /> Actors  : (233168,122)<br /> <br /> * Max = 3000<br /> Single  : (2098500,33)<br /> Pool    : (2098500,203)<br /> PoolJava: (2098500,147)<br /> Actors  : (2098500,216)<br /> <br /> * Max = 10000<br /> Single  : (23331668,48)<br /> Pool    : (23331668,189)<br /> PoolJava: (23323633,355)<br /> Actors  : (23331668,417)<br /> <br /> * Max = 30000<br /> Single  : (209985000,62)<br /> Pool    : (209985000,170)<br /> PoolJava: (209985000,425)<br /> Actors  : (209985000,138)<br /> <br /> * Max = 100000<br /> Single  : (2333316668,12)<br /> Pool    : (2333316668,518)<br /> PoolJava: (2333253053,1103)<br /> Actors  : (2333316668,315)<br /> <br /> Pelo visto ainda há muito o que aprender nesta área. <br /> Mas vou seguir sua sugestão e tentar com algo que exija mais mais processamento, como verificar quais números de 0 até N são primos por exemplo.<br /> <br /> Grato, <br /> <br /> [/quote]<br /> <br /> Voce já falou em multiprocessamento, paralelismo, pool de threads, processamento distribuído alá actors... e eu continuo sem entender que resultados espera conseguir.<br /> <br /> Não tem nada de pouco processamento no seu exemplo, como pode ser visto pelos resultados exibidos, vc é que esta distribuindo a carga de maneira errada como falei no primeiro post.]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197163/991775/reprocessamento-paralelo-em-scala
</guid>
				<link>http://www.guj.com.br/prepost/197163/991775/reprocessamento-paralelo-em-scala
</link>
				<pubDate><![CDATA[Mon, 8 Feb 2010 08:28:23]]> GMT</pubDate>
				<author><![CDATA[ mochuara]]></author>
			</item>
			<item>
				<title>Re:Processamento Paralelo em Scala</title>
				<description><![CDATA[ Problema 1 do projeto euler em clojure:<br /> <br /> [code](reduce + (filter (fn [n] (or (zero? (rem n 3))<br />                               (zero? (rem n 5))))<br />                   (range 1000)))[/code]<br /> <br /> Em scala:<br /> <br /> [code](1 until 1000).filter(n =&gt; n % 3 == 0 || n % 5 == 0).foldLeft(0)(_ + _)[/code]]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197163/991777/reprocessamento-paralelo-em-scala
</guid>
				<link>http://www.guj.com.br/prepost/197163/991777/reprocessamento-paralelo-em-scala
</link>
				<pubDate><![CDATA[Mon, 8 Feb 2010 08:33:51]]> GMT</pubDate>
				<author><![CDATA[ mochuara]]></author>
			</item>
			<item>
				<title>Re:Processamento Paralelo em Scala</title>
				<description><![CDATA[ [quote=mochuara]<br /> Voce já falou em multiprocessamento, paralelismo, pool de threads, processamento distribuído alá actors... e eu continuo sem entender que resultados espera conseguir.<br /> <br /> Não tem nada de pouco processamento no seu exemplo, como pode ser visto pelos resultados exibidos, vc é que esta distribuindo a carga de maneira errada como falei no primeiro post.[/quote]<br /> Me desculpe se não estou sendo claro, vou dar um exemplo do que eu pretendo: <br /> Digamos que estou numa sequencia e no momento estou em 1013 (que é primo). Enquanto rodo a verificação de sua "primalidade", poderia paralelamente verificar 1014 (divisivel por 2)*, 1015 (por 5), 1016 (por 2) e 1017 (por 3), cuja verificação é mais rápida, pois seus divisores são pequenos. Ou seja enquanto um thread faz uma verificação mais demorada, outra pode fazer uma verificação mais rápida e passar para o próximo número disponível. E quando a primeira thread terminar sua verificação tamém pegaria o próximo número da fila.<br /> <br /> * Claro que um algorítmo de verdade pularia os números pares, estou apenas dando um exemplo.<br /> <br /> Grato, ]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197163/991873/reprocessamento-paralelo-em-scala
</guid>
				<link>http://www.guj.com.br/prepost/197163/991873/reprocessamento-paralelo-em-scala
</link>
				<pubDate><![CDATA[Mon, 8 Feb 2010 10:34:39]]> GMT</pubDate>
				<author><![CDATA[ Rafael Afonso]]></author>
			</item>
			<item>
				<title>Re:Processamento Paralelo em Scala</title>
				<description><![CDATA[ Parece que esse tipo de problema não é um bom candidato para processamento paralelo:<br /> <br /> <a class="snap_shots" href="http://groups.google.com/group/clojure/msg/47030e46692dcffd" target="_blank" rel="nofollow">http://groups.google.com/group/clojure/msg/47030e46692dcffd</a>]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197163/992374/reprocessamento-paralelo-em-scala
</guid>
				<link>http://www.guj.com.br/prepost/197163/992374/reprocessamento-paralelo-em-scala
</link>
				<pubDate><![CDATA[Tue, 9 Feb 2010 08:16:57]]> GMT</pubDate>
				<author><![CDATA[ mochuara]]></author>
			</item>
	</channel>
</rss>
