title: Slick threadLocalSession vs implicit session
body: <p>I encountered this problem while posting this question: <a href="https://stackoverflow.com/questions/20694323/slick-write-a-simple-table-creation-function/">Slick Write a Simple Table Creation Function</a></p>
  
  <p>I am very new to Slick and concurrency, knowing only the basics. I worked with JDBC before, but in there you have to manually open a session and then close it. Nothing goes beyond that, and there is very little automation (at least I didn't have to make automated process).</p>
  
  <p>However, I get confused with Slick session. In the tutorial, the example "Getting Started" encourages people to use <code>threadLocalSession</code>:</p>
  
  <blockquote>
    <p>// Use the implicit threadLocalSession </p>
    
    <p>import Database.threadLocalSession</p>
  </blockquote>
  
  <p><a href="http://slick.typesafe.com/doc/1.0.0/gettingstarted.html" rel="nofollow noreferrer">http://slick.typesafe.com/doc/1.0.0/gettingstarted.html</a></p>
  
  <p>The original recommendation is: </p>
  
  <blockquote>
    <p>The only extra import we use is the threadLocalSession. This
    simplifies the session handling by attaching a session to the current
    thread so you do not have to pass it around on your own (or at least
    assign it to an implicit variable).</p>
  </blockquote>
  
  <p>Well, I researched a bit online, and some people suggest not to use threadLocalSession and only use implicit session. Some suggest using threadLocalSession.</p>
  
  <p>One reason to support implicit session is that "makes sure at compile time that you have a session". Well, I only have two questions:</p>
  
  <ol>
  <li><p>When people use "thread", are they referring to concurrency? Slick/JDBC data storage was handled through concurrency?</p></li>
  <li><p>Which way is better? Implicit or threadLocalSession? Or when to use which?</p></li>
  <li><p>If it is not too much to ask, I read the syntax of <code>{implicit session:Session =&gt; ...}</code> somewhere in my Scala book, and I forgot where it was. What's this expression?</p></li>
  </ol>