2016年3月23日

on the go way (six)the usage of select which prevent form blocking

when used the select word ,sometimes it may be blocked ,we can use the timer to prevent form being blocking

which used as follows:

 1 package main
 2 
 3 import (
 4     "fmt"
 5     "time"
 6 )
 7 
 8 func main() {
 9     c := make(chan int)
10     o := make(chan bool)
11     go func() {
12         for {
13             select {
14             case v := <-c:
15                 fmt.Println("result is ", v)
16             case a := <-time.After(5 * time.Second):
17                 fmt.Println("time out", a)
18                 o <- true
19                 break
20             }
21         }
22     }()
23 
24     <-o
25 }

 

posted @ 2016-03-23 12:01 AAAAAApple 阅读(262) 评论(0) 推荐(0) 编辑

2016年3月22日

on the go way (五)git push 403 error

摘要: 在使用git push的时候产生这种情况 error: The requested URL returned error: 403 while accessing https://github.comgit/info/refs 阅读全文

posted @ 2016-03-22 20:32 AAAAAApple 阅读(105) 评论(0) 推荐(0) 编辑

on the go way (四)select 的用法

摘要: 在channel 和gorutine的联合使用中,select的结合使用也越来越多 阅读全文

posted @ 2016-03-22 16:22 AAAAAApple 阅读(190) 评论(0) 推荐(0) 编辑

on the go way (三)channel 的用法

摘要: 3)关闭无缓存的channel不会阻塞 对于关闭的channel 没有buffer的channel 读出来的为对应的0值,但如果往里面写数据的话会产生panic 4)关闭有缓存的channel 关闭之后可以读出来~但是写入还是引发panic 5)nil channel发生阻塞 阅读全文

posted @ 2016-03-22 15:09 AAAAAApple 阅读(239) 评论(0) 推荐(0) 编辑

on the go way (二)channel 的用法

摘要: 在Go语言中channel的使用方法有很多,首先来看以下的使用方法 1)当作事件信号来用,当某一件事完成之后,通知另一件事的完成 2)多个线程同时进行 阅读全文

posted @ 2016-03-22 14:01 AAAAAApple 阅读(398) 评论(0) 推荐(0) 编辑

2016年3月21日

on the go way (一)服务器并发

摘要: 服务器并发的方式有很多种 1.通过多进程或者多线程的方式,现在这种模式基本上已经不用 2.epoll和IOCP回调的方式,不符合人们的习惯 3.使用协程(轻量级线程,创建、销毁的代价很小),协程在逻辑上上顺序执行 其中属于erlang和golang在协程并发方面做的比较好 package maini 阅读全文

posted @ 2016-03-21 11:43 AAAAAApple 阅读(202) 评论(0) 推荐(0) 编辑

2016年1月28日

ubuntu iso 镜像网址

摘要: http://ftp.sjtu.edu.cn/ 阅读全文

posted @ 2016-01-28 16:38 AAAAAApple 阅读(156) 评论(0) 推荐(0) 编辑

2015年8月4日

linux 下的git和github使用方法

摘要: 1 Linux下Git和GitHub环境的搭建第一步: 安装Git,使用命令 “sudo apt-get install git”第二步: 创建GitHub帐号第三步: 生成ssh key,使用命令 “ssh-keygen -t rsa -C "your_email@youremail.com"”,... 阅读全文

posted @ 2015-08-04 14:26 AAAAAApple 阅读(369) 评论(0) 推荐(0) 编辑

2015年6月10日

PKU OJ 进阶学习篇(JunWangUSTC+追梦)

摘要: 【pku_1001】* 题目阐述: 简单的A+B 解决方法: 水题 代码: 1 #include 2 3 4 int main() 5 { 6 7 int a,b; 8 scanf("%d %d",&a,&b); 9 print... 阅读全文

posted @ 2015-06-10 16:02 AAAAAApple 阅读(209) 评论(0) 推荐(0) 编辑

2014年11月11日

双11上图片

摘要: 阅读全文

posted @ 2014-11-11 15:05 AAAAAApple 阅读(148) 评论(0) 推荐(0) 编辑

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

导航

统计

点击右上角即可分享
微信分享提示