{"action":"created","issue":{"url":"https://api.github.com/repos/AkkaChina/usergroup/issues/3","labels_url":"https://api.github.com/repos/AkkaChina/usergroup/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/AkkaChina/usergroup/issues/3/comments","events_url":"https://api.github.com/repos/AkkaChina/usergroup/issues/3/events","html_url":"https://github.com/AkkaChina/usergroup/issues/3","id":96710561,"number":3,"title":"循环测试tell 发送没有跑完","user":{"login":"solq360","id":6812182,"avatar_url":"https://avatars.githubusercontent.com/u/6812182?v=3","gravatar_id":"","url":"https://api.github.com/users/solq360","html_url":"https://github.com/solq360","followers_url":"https://api.github.com/users/solq360/followers","following_url":"https://api.github.com/users/solq360/following{/other_user}","gists_url":"https://api.github.com/users/solq360/gists{/gist_id}","starred_url":"https://api.github.com/users/solq360/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solq360/subscriptions","organizations_url":"https://api.github.com/users/solq360/orgs","repos_url":"https://api.github.com/users/solq360/repos","events_url":"https://api.github.com/users/solq360/events{/privacy}","received_events_url":"https://api.github.com/users/solq360/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-23T02:24:17Z","updated_at":"2015-07-23T02:26:57Z","closed_at":null,"body":"测试代码\r\n```\r\n\t\tfinal ActorSystem system = ActorSystem.create(\"test\");\r\n\t\tfinal ActorRef greeter = system.actorOf(Props.create(Greeter.class),\r\n\t\t\t\t\"order\");\r\n\t\tint i = 0;\r\n\t\tfor (; i < 1000000; i++) {\r\n\t\t\tgreeter.tell(new WhoToGreet(\"hello\"), ActorRef.noSender());\r\n\t\t}\r\n\t\t\r\n\t\tSystem.out.println(i);\r\n```\r\n\r\n测试对象\r\n\r\n```\r\npublic static class WhoToGreet implements Serializable {\r\n\t\tpublic final String who;\r\n\r\n\t\tpublic WhoToGreet(String who) {\r\n\t\t\tthis.who = who;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\r\n\tpublic static class Greeter extends UntypedActor {\r\n\t\tString greeting = \"\";\r\n\r\n\t\tprivate long count1;\r\n\t\tprivate long count2;\r\n\r\n\t\tprivate Date start1;\r\n\t\tprivate Date start2;\r\n\r\n\t\tpublic void onReceive(Object message) {\r\n\t\t\tif (message instanceof WhoToGreet) {\r\n\t\t\t\tgreeting = \"hello, \" + ((WhoToGreet) message).who;\r\n\t\t\t\tcount1++;\r\n\t\t\t\tif (start1 == null) {\r\n\t\t\t\t\tstart1 = new Date();\r\n\t\t\t\t}\r\n\t\t\t} else if (message instanceof Greet) {\r\n\t\t\t\tgetSender().tell(new Greeting(greeting), getSelf());\r\n\t\t\t\tcount2++;\r\n\t\t\t\tif (start2 == null) {\r\n\t\t\t\t\tstart2 = new Date();\r\n\t\t\t\t}\r\n\t\t\t\t// System.out.println(\" tell Greet ============================ \");\r\n\t\t\t} else\r\n\t\t\t\tunhandled(message);\r\n\r\n\t\t\tif (start1 != null) {\r\n\t\t\t\tlong t = new Date().getTime() - start1.getTime();\r\n\t\t\t\t//if (t % 1000 != 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tdouble d = count1 / Double.valueOf((t / 1000));\r\n\t\t\t\t\t//System.out.println(\" 1 rps : \" + d);\r\n\t\t\t\t\tSystem.out.println(\" count : \" + count1);\r\n\t\t\t\t\t//System.out.println(\" time : \" + t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n//\t\t\tif (count2 % 1000 == 0 && start2 != null) {\r\n//\t\t\t\tdouble d = count2\r\n//\t\t\t\t\t\t/ Double.valueOf((new Date().getTime() - start2\r\n//\t\t\t\t\t\t\t\t.getTime() / 1000));\r\n//\t\t\t\tSystem.out.println(\" 2 psd : \" + d);\r\n//\t\t\t}\r\n\t\t}\r\n\t}\r\n```\r\n\r\n测试结果:\r\n count : 6568\r\n count : 6569\r\n\r\n没有执行完循环\r\n\r\n环境 : \r\n* jdk1.7\r\n\r\n<dependency>\r\n<groupId>com.typesafe.akka</groupId>\r\n<artifactId>akka-actor_2.10</artifactId>\r\n<version>2.3.6</version>\r\n</dependency>\r\n\t\t\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/AkkaChina/usergroup/issues/comments/123934856","html_url":"https://github.com/AkkaChina/usergroup/issues/3#issuecomment-123934856","issue_url":"https://api.github.com/repos/AkkaChina/usergroup/issues/3","id":123934856,"user":{"login":"Kabie","id":492619,"avatar_url":"https://avatars.githubusercontent.com/u/492619?v=3","gravatar_id":"","url":"https://api.github.com/users/Kabie","html_url":"https://github.com/Kabie","followers_url":"https://api.github.com/users/Kabie/followers","following_url":"https://api.github.com/users/Kabie/following{/other_user}","gists_url":"https://api.github.com/users/Kabie/gists{/gist_id}","starred_url":"https://api.github.com/users/Kabie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kabie/subscriptions","organizations_url":"https://api.github.com/users/Kabie/orgs","repos_url":"https://api.github.com/users/Kabie/repos","events_url":"https://api.github.com/users/Kabie/events{/privacy}","received_events_url":"https://api.github.com/users/Kabie/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T02:26:57Z","updated_at":"2015-07-23T02:26:57Z","body":"主线程退出就结束了……\r\n`Main` 最后 `readline` 一下就好了"}}