import time

class Snow(object):

    def __init__(self, idx=None):
init_date = time.strptime('2010-01-01 00:00:00', "%Y-%m-%d %H:%M:%S")
self.start = int(time.mktime(init_date))
self.last = int(time.time())
self.count_id = 0
self.idx = idx if idx else 0 def get(self):
now = int(time.time())
temp = now - self.start
if len(str(temp)) < 9:
length = len(str(temp))
s = '0' * (9 - length)
temp = s + str(temp)
if now == self.last:
self.count_id += 1
else:
self.count_id = 0
self.last = now
if len(str(self.idx)) < 2:
length = len(str(self.idx))
s = '0' * (2 - length)
self.idx = s + str(self.idx)
if self.count_id == 99999:
time.sleep(1)
count_id_data = str(self.count_id)
if len(count_id_data) < 5:
length = len(count_id_data)
s = '0' * (5 - length)
count_id_data = s + count_id_data
return ''.join([temp, self.idx, count_id_data]) if __name__ == '__main__':
import threading
snow = Snow('001') def echo():
print(snow.get()) threads = [threading.Thread(target=echo) for i in range(100)]
for t in threads:
t.start()
for t in threads:
t.join()

最新文章

  1. 7.11 数据注解特性--InverseProperty
  2. [Java Web]Error parsing HTTP request header Note: further occurrences of HTTP header parsing errors
  3. 【bzoj1500】 noi2005—维护数列
  4. SharePoint固定的Footer
  5. Android适配器之ArrayAdapter、SimpleAdapter和BaseAdapter的简单用法与有用代码片段(转)
  6. 在Tomcat里使用配置连接池连接数据库
  7. C#各类型大小
  8. Kettle ETL 来进行mysql 数据同步——试验环境搭建(表中无索引,无约束,无外键连接的情况)
  9. WordPress &#39;is_serialized()&#39;远程任意代码执行漏洞(CVE-2013-4338)
  10. PHP数据学习-二维数组【3】
  11. html 商品展示框
  12. Java中实例方法,实例变量,静态方法,静态变量,final方法重写的问题,覆盖
  13. POJ 2007 Scrambled Polygon 凸包
  14. Ajax调用asp.net后台代码
  15. Spring Security入门(3-6)Spring Security 的鉴权 - 自定义权限前缀
  16. Android 插件化技术窥探
  17. C语言随机数使用方法
  18. 2016年,总结篇 续 如何从 JQ 转到 VueJS 开发(一)
  19. container
  20. python中pip升级

热门文章

  1. PAT 1145 1078| hashing哈希表 平方探测法
  2. 题解:swj社会摇基础第一课
  3. ubuntu下的mv命令
  4. java自定义词典使用Hanlp
  5. 20K掌握的技术要点?
  6. hdu6470 矩阵快速幂+构造矩阵
  7. 全国省市区 json sql 支付宝 2019年9月29日
  8. 使用Vue封装暂无数据占位图组件
  9. 奇安信集团笔试题:二叉树的最近公共祖先(leetcode236),杀死进程(leetcode582)
  10. python批量裁剪图片