title: Go concurrent access to pointers methods
body: <p>I'm trying to understand what happens when you make concurrent access to a pointers methods?</p>
  
  <p>I have a map of pointers and spawn off a few go routines.  I pass the map into each go routine  and each go routine will use one of the values in the map. Nothing is being written to the map only being read from.</p>
  
  <p>The map is small, only 4 keys so it's possible that more than one go routine will be using the same value from the map. </p>
  
  <p>Question is, what happens when two go routines call a method of the same pointer?  Will I get unpredictable results?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Example:  I'm taking out the map portion as that's not the question I'm after.</p>
  
  <p>I have <code>foo</code> which is a pointer of type <code>MyStruct</code> and this structure has a method <code>DoSomething</code> that takes arguments.  In the <code>main</code> function I'm creating two <code>go routines</code> and both of them make calls to <code>foo.DoSomething</code> passing different values.  In this example the first go routine has a much larger calculation to preform than the second one (just using sleep times here to simulate calculations).  Again nothing in the structure is changing I'm only making a call to the structures method. Do I have to worry about the second go routine making a call to <code>foo.DoSomething</code> when the first go routine is still working with the method?</p>
  
  <pre><code>package main
  
  import (
      "log"
      "time"
  )
  
  type MyStruct struct {
  }
  
  func (self *MyStruct) DoSomething(value int) {
  
      log.Printf("%d Start", value)
  
      calculation_time := time.Duration(value) * time.Second
      log.Printf("%d Calculating", value, calculation_time)
      time.Sleep(calculation_time)
  
      log.Printf("%d Done", value)
  }
  
  func main() {
  
      var foo = new(MyStruct)
  
      go foo.DoSomething(5)
  
              // is this method call a problem when the first one is still working?
      go foo.DoSomething(2)
  
      time.Sleep(time.Duration(6 * time.Second))
  }
  </code></pre>