This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 相比sieve.go,内存占用少很多哦 - 对比 http://gist.github.com/257036 | |
import stackless | |
def generate(channel): | |
i = 2 | |
while True: | |
channel.send(i) | |
i = i+1 | |
def filter_prime(in_chan, out_chan, prime): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2009 The Go Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
package main | |
import "fmt" | |
// Send the sequence 2, 3, 4, ... to channel 'ch'. | |
func generate(ch chan int) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//From http://hg.openjdk.java.net/jdk7/jdk7/jdk/raw-file/bfd7abda8f79/src/share/classes/java/util/TimSort.java | |
/* | |
* Copyright 2009 Google Inc. All Rights Reserved. | |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
* | |
* This code is free software; you can redistribute it and/or modify it | |
* under the terms of the GNU General Public License version 2 only, as | |
* published by the Free Software Foundation. Sun designates this | |
* particular file as subject to the "Classpath" exception as provided |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.actors.{Actor} | |
import scala.actors.Actor._ | |
import java.util.concurrent.CountDownLatch | |
object Main { | |
val PROCESSER_COUNT=Runtime.getRuntime().availableProcessors() | |
var perThreadRequests=10000 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package coroutine.kilim.benchmark; | |
import java.util.concurrent.CountDownLatch; | |
import kilim.Mailbox; | |
import kilim.Pausable; | |
import kilim.Task; | |
public class Main { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding=utf-8 | |
import stackless | |
import sys | |
import time | |
per_thread_requests = 10000 | |
def receive_task(): | |
for i in xrange(0, per_thread_requests): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Scala parallel version smallpt of http://www.cnblogs.com/miloyip/archive/2010/07/07/languages_brawl_GI.html | |
package parallel | |
class RandomLCG(var seed:Long) { | |
def nextDouble(): Double = { | |
seed = (214013L * seed + 2531011L) % 0x100000000L | |
seed * (1.0 / 4294967296.0) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
public class Test { | |
public static void main(String[] args) { | |
List<? extends Fruit> list = new ArrayList<Fruit>(); | |
List<? super Apple> list1 = new ArrayList<Apple>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Found on http://www.alternateinterior.com/2007/05/multi-threading-strategies-in-php.html | |
//Modified by http://www.php-code.net | |
//Modified: add executor | |
class Thread { | |
var $pref ; // process reference | |
var $pipes; // stdio | |
var $buffer; // output buffer | |
var $output; | |
var $error; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r a0c46f1a4e8b src/main/java/org/jboss/netty/channel/socket/DefaultSocketChannelConfig.java | |
--- a/src/main/java/org/jboss/netty/channel/socket/DefaultSocketChannelConfig.java Thu Jun 02 14:13:48 2011 +0800 | |
+++ b/src/main/java/org/jboss/netty/channel/socket/DefaultSocketChannelConfig.java Thu Jun 02 16:55:06 2011 +0800 | |
@@ -17,6 +17,7 @@ | |
import java.net.Socket; | |
import java.net.SocketException; | |
+import java.util.concurrent.TimeUnit; | |
import org.jboss.netty.channel.ChannelException; |