daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Sep 12th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // na base
  2. func main() {
  3.  
  4.     // conexao
  5.     Db := Conn.Connet()
  6.  
  7.     // Exemplo 1
  8.     // posso fazer milhares de
  9.     // chamadas e ele retorna sempre
  10.     // a instancia que esta em memoria
  11.     go func() {
  12.  
  13.         for i := 0; i < 10000000; i++ {
  14.  
  15.             Db = Conn.Connet()
  16.             fmt.Println("Goroutine1 Connect: ", i)
  17.             time.Sleep(time.Millisecond * 50)
  18.         }
  19.     }()
  20.  
  21.     // Exemplo 2
  22.     // criando 200 goroutines
  23.     for x := 0; x < 200; x++ {
  24.         go func(x int) {
  25.             for j := 0; j < 10000; j++ {
  26.                 fmt.Printf("Goroutine2 Connect: %d -> %d", x, j)
  27.                 fmt.Printf(" login: %s", Conn.Connet().GetUserEmail(x))
  28.                 time.Sleep(time.Millisecond * 150)
  29.             }
  30.         }(x)
  31.     }
  32.     fmt.Scanln()
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top