ICode9

精准搜索请尝试: 精确搜索
  • setTimeout 模拟setInterval2022-07-05 16:05:03

      当我们使用setInterval函数来实现间隔一段时间执行一段代码的时候, 如果回调函数花费的时间远大于时间间隔,那么就不会在规定时间间隔执行回调函数, 因为JavaScript的运行机制是先清空执行栈里面的任务,如果执行栈空了,然后去任务队列里面取出任务放到执行栈执行,也就是所谓的js的eve

  • golang 等待一组goroutine完成,并带返回值(2)2021-10-26 14:02:35

    // https://github.com/AaronJan/Hunch ctx := context.Background() r, err := hunch.All( ctx, func(ctx context.Context) (interface{}, error) { time.Sleep(300 * time.Millisecond) return 1, nil }, func(ctx context.Context) (int

  • go duration比较2021-10-14 15:02:40

    func Test() { var waitFiveHundredMillisections time.Duration = 500 * time.Millisecond startingTime := time.Now().UTC() time.Sleep(600 * time.Millisecond) endingTime := time.Now().UTC() var duration time.Duration = endingTime.Sub(startingTime) if duration

  • JAVA-日期处理-LocalDate-时区2021-05-08 17:02:18

      三种时区表示方式,LocalDate转成字符串日期和ts的方法 LocalDateTime localDateTime = null; //时区写法1: String timezone = "Asia/Shanghai"; //###### 字符串时间转ts ZoneId zoneId = ZoneId.of(timezone); localDateTime = LocalDateTime.par

  • java 多次尝试执行任务,直到成功或次数用完2021-04-29 20:34:39

    直接上代码: public class TaskUtil { /** * 多次尝试执行任务,直到成功或次数用完 * @param task 任务 * @param times 循环次数 * @param millisecond 两个任务之间休眠时间(单位:毫秒) * @param <T> * @return */ public static <T> T

  • Go并发之锁2021-01-22 13:03:40

    互斥锁 package main import ( "fmt" "sync" "time" ) //使用互斥锁计算时间 var( mu sync.Mutex x int64 wg sync.WaitGroup ) func write() { defer wg.Done() mu.Lock() x = x+1 time.Sleep(time.Millisecond*10) mu.Unlock() } func

  • 从零开始学Go之并发(三):Select2019-07-02 12:50:55

    select 是 Go 中类似于用于通信的 switch 语句。每个 case 必须是一个通信操作,要么是发送要么是接收 select 随机执行一个可运行的 case,如果没有 case 可运行,它将阻塞,直到有 case 可运行 一个默认的子句应该总是可运行的 当select中的其它分支都没有准备好时,default分支就会执行 se

  • Android 开发 倒计时功能 转载2019-03-27 12:45:01

    原文地址:https://www.cnblogs.com/xch-yang/p/7920419.html Android为我们封装好了一个抽象类CountDownTimer,可以实现计时器功能:   /** * 倒数计时器 */ private CountDownTimer timer = new CountDownTimer(15 * 60 * 1000, 1000) { Android为我们封装好了一个

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有