还未发布过话题
  • 我这样是不是跑题了?😅

    func main()  {
        rand.Seed(time.Now().Unix())
        ics := make([]chan int,0)
        nums := make([]int,0)
        for i := 0; i < 10; i++ {
            ic := make(chan int)
            ics = append(ics,ic)
            go outputRand(ic)
            r := rand.Intn(100)
            nums = append(nums,r)
        }
    
        sort.SliceStable(nums, func(i, j int) bool {
            return nums[i] < nums[j]
        })
    
        for i, value := range nums {
            ics[i] <- value
            time.Sleep(1 * time.Millisecond)
        }
    }
    
    func outputRand(wg chan int)  {
        fmt.Println(<-wg)
    }
    
  • 👍 👍 👍

  • 看懂了的请点个赞,统计下看看~~