自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(32)
  • 资源 (1)
  • 收藏
  • 关注

原创 python 中的队列

queue 可以保证每个线程取和存数据的安全性,因为它里面实现了锁机制#-*-coding:utf-8-*- #__author:martin#date:2017/10/23import threadingimport randomimport timeclass Producer(threading.Thread): def run(self): globa

2017-10-24 22:01:53 288

原创 python 生产者和消费者

#-*-coding:utf-8-*- #__author:martin#date:2017/10/23import threadingimport randomimport timeclass Producer(threading.Thread): def run(self): global L while True:

2017-10-23 22:04:18 434

原创 lambda表达式

package com.brendan.cn.java8;import java.util.ArrayList;import java.util.Arrays;import java.util.List;import java.util.function.Predicate;public class TestMain { public static void main(String[]

2017-10-23 21:03:13 204

转载 phaser

创建三个线程在三个目录里查找一天以内修改过的以log结尾的文件并打印出来, 线程与线程之间通过phaser来保持同步点package com.brendan.cn.concurrent.phaser;import java.io.File;import java.util.ArrayList;import java.util.Date;import java.util.List;impor

2017-10-23 20:51:43 215

原创 TreeMap

import java.util.Comparator;import java.util.Map;import java.util.TreeMap;public class TestTreeMap { public static void main(String[] args) { new TestTreeMap().test(); } void tes

2017-10-23 20:11:47 148

原创 ArrayBlockingQueue

public class TestArrayBlockingQueue { public static void main(String[] args) throws InterruptedException { BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(3); for(int i

2017-10-23 20:10:33 153

原创 cyclicBarrier

import java.util.concurrent.BrokenBarrierException;import java.util.concurrent.CyclicBarrier;public class TestCyclicBarrier { public static void main(String[] args) throws InterruptedException, Br

2017-10-23 20:07:09 316

原创 deadLock

public class DeadLock { private static Object o1 = new Object(); private static Object o2 = new Object(); public static void main(String[] args) { new Thread(()->{

2017-10-23 20:04:49 244

原创 jion

public class TestJoin { public static void main(String[] args) { MyThread2 t1 = new MyThread2("TestJoin"); t1.start(); try { t1.join(); //join()合并线程,子线程运行完之后,主线程才

2017-10-23 20:03:47 478

原创 python 中的semaphore

控制并发的线程数#-*-coding:utf-8-*- #__author:martin#date:2017/10/22import threadingimport timeclass Mythread(threading.Thread): def run(self): if semaphore.acquire(): print(self.na

2017-10-22 20:03:03 898

原创 python线程

创建两个线程,并运行#-*-coding:utf-8-*-#__author:martin#date:2017/10/22import threadingclass Mythread(threading.Thread): def __init__(self,num): threading.Thread.__init__(self) self.num =

2017-10-22 11:09:47 186

原创 python中线程和进程

1.进程是cpu资源分配的最小单位,线程是cpu调度的最小单位 2.一个进程里可以包含多个线程,线程之间可以直接通讯,每个线程都有自己的线程栈,并可以访问线程属于的进程的资源。而进程通讯要通过其他的方式,比如队列等等 3.创建线程开销小,创建进程开销大 4.在python中,由于有全局解释器锁(GIL)的原因,同一时刻一个进程下的线程只能分配给一个cpu去执行。所以python适合的是IO密集

2017-10-22 09:04:05 261

原创 python中的socketserver

socketserver 实际上是为了简化socket编程#-*-coding:utf-8-*- #__author:martin#date:2017/10/21import socketimport socketserverclass MyServer(socketserver.BaseRequestHandler): def handle(self): print

2017-10-21 20:28:04 389

原创 python编码解码

#-*-coding:utf-8-*- #__author:martin#date:2017/10/21s = 'hello可乐'#编码 str类型 ---> 16进制bytes类型b = s.encode('utf8')print(type(b))print(b)#b'hello\xe8\x99\x8e'#解码 16进制bytes类型--->str类型 s_n = str(b

2017-10-21 16:02:45 415

原创 python中的单例

#-*-coding:utf-8-*- #__author:martin#date:2017/10/19class Foo: __v = None @classmethod def getInstance(cls): if cls.__v: return cls.__v else: cls.

2017-10-19 20:53:43 247

原创 python类名()的执行过程

#-*-coding:utf-8-*- #__author:martin#date:2017/10/18class MyType(type): def __init__(self,*args,**kwargs): print("遇到类名....") def __call__(self, *args, **kwargs): print('类名加()

2017-10-18 21:14:22 1457

转载 IntelliJ IDEA 15 创建maven项目

IntelliJ IDEA 15 创建maven项目 <div class="postBody"> <div id="cnblogs_post_body"><h1 id="autoid-0-0-0">说明</h1>创建Maven项目的方式:手工创建好处:参考IntelliJ IDEA 14 创建maven项目二(此文章描述了用此方式创建Ma

2017-10-17 20:15:11 247

原创 python 面向对象继承

#-*-coding:utf-8-*- #__author:martin#date:2017/10/15class F: def f1(self): print('F.f1')class S(F): def f1(self): #super(S,self).f1() #执行父类的方法,第一种方式,常用这种方式 F.f1(self)

2017-10-15 09:36:58 163

原创 python 使用json模块

#-*-coding:utf-8-*- #__author:martin#date:2017/10/14import json# dic = {'name':'martin','age':20}# data = json.dumps(dic)# f = open('test.txt','w')# f.write(data)# f.close()f = open('test.txt','

2017-10-14 09:27:22 212

转载 httpclient工具类

http发送post ,get请求的工具类import java.io.IOException;import java.net.URL;import java.util.ArrayList;import java.util.List;import java.util.Map;import org.apache.http.NameValuePair;import org.apache.htt

2017-10-12 21:10:49 275

原创 python 利用正则实现简易计算器

#-*-coding:utf-8-*-#__author:martin#date:2017/10/11import redef f_string(s): s = s.replace(' ','') s = s.replace('++', '+') s = s.replace('--', '+') s = s.replace('+-', '-') return

2017-10-11 23:05:55 563

原创 python 中的正则

匹配数字 \d,字符符号\w,空白符号\s,特殊边界\b# ret = re.findall('\d+','12344eee')# print(ret)# ret = re.findall('\smart',' ad mart')# print(ret)# ret = re.findall('\w',' ad mart')# print(ret)# ret = re.findall(r'm\b

2017-10-10 21:54:10 335

原创 python记录日志

#-*-coding:utf-8-*- #__author:martin#date:2017/10/9import loggingimport sys#获取logger实例,如果参数为空则返回root loggerlogger = logging.getLogger("AppName")# 指定logger输出格式formatter = logging.Formatter('%(asc

2017-10-09 22:01:04 1906

原创 python 生成器

生成器的作用是边循环边计算,节约内存#定义一个生成器def foo(): print('www') yield 1 print('martin') yield 2#这里得到生成器,并不是执行函数g = foo()for i in g: print(i)www 1 martin 2裴波那契数列def fibo(indx): n ,bef

2017-10-07 14:24:24 141

原创 python 里装饰器

装饰器就是给原理的函数添加新的功能,用到了闭包#需要添加的功能def show_time(fun): def inner(): start = time.time() fun() end = time.time() print(end-start) return inner#功能函数def foo():

2017-10-06 23:04:15 116

原创 python 中的闭包

内部函数引用了外部作用域的变量def outer(): x = 100 def inner(): print(x) return innerouter()()100

2017-10-06 22:07:39 120

原创 python 内置函数

#filterdef fun1(s): if s != 'a': return sstr = ['a','b','c','d']f1 = filter(fun1 , str)print(list(f1))['b', 'c', 'd']#mapstr = ['1','2','3']def fun2(s): return s+'martin'var =

2017-10-06 21:34:03 223

原创 python 里的集合

c1 = set('abc')print(c1)c1.add('zh')print(c1)c2 = set('abc')print(c2)c2.update('zh')print(c2){‘b’, ‘c’, ‘a’} {‘zh’, ‘b’, ‘c’, ‘a’} {‘b’, ‘c’, ‘a’} {‘z’, ‘h’, ‘c’, ‘a’, ‘b’}

2017-10-06 11:59:19 146

原创 python 浅copy 和 深copy

浅copy 只copy第一层第一种情况s = [‘martin’,’decoration’,123] s1 = s.copy() s1[0]= ‘s’ print(s1) print(s)[’s’, ‘decoration’, 123] [‘martin’, ‘decoration’, 123]第二种情况v = [[1,2],3,4] b= v.copy() b[0][0] =

2017-10-05 22:47:27 199

原创 python 打印1-100所有的奇数

for i in range(1,101): if i % 2 == 1: print(i)

2017-10-01 22:21:43 25507

原创 python打印乘法表

i = 1while i <= 9: j = 1 while j <= i : print(j ,"*", i , "=" , j*i,end="\t") j += 1 print() i += 1

2017-10-01 19:30:14 515

原创 python变量赋值

1、python 的安装目录 D:\development\Python362、 将D:\development\Python36 加入到环境变量path ,查看版本 3、在E:\python文件夹里新建一个test.py文件,内容如下name = "jack"name2 = namename = "martin"print(name,name2)4、以管理员身份打开命令行,进入 E

2017-10-01 08:52:01 345

nginx for window7

nginx for window7 负载均衡

2017-07-30

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除