gopool

package module
v0.0.0-...-d7d56d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2022 License: BSD-2-Clause Imports: 1 Imported by: 2

README

go线程池使用方法

package main

import (
	"fmt"
	"github.com/orestonce/gopool"
)

func main() {
	task := gopool.NewThreadPool(10) // 最大线程数
	task.AddJob(func() {
		fmt.Println("thread1")
	})
	task.AddJob(func() {
		fmt.Println("thread2")
	})
	task.CloseAndWait()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ThreadPool

type ThreadPool struct {
	// contains filtered or unexported fields
}

func NewThreadPool

func NewThreadPool(maxSize int) *ThreadPool

func (*ThreadPool) AddJob

func (this *ThreadPool) AddJob(fn func())

func (*ThreadPool) CloseAndWait

func (this *ThreadPool) CloseAndWait()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL