title: scala ZIO foreachPar
body: <p>I'm new to parallel programming and ZIO, i'm trying to get data from an API, by parallel requests.</p>
  <pre><code>import sttp.client._
  import zio.{Task, ZIO}
  
  
  ZIO.foreach(files) { file =&gt;
      getData(file)
      Task(file.getName)
    }
  
  
  def getData(file: File) = {
  
    val data: String = readData(file)
    val request = basicRequest.body(data).post(uri&quot;$url&quot;)
        .headers(content -&gt; &quot;text&quot;, char -&gt; &quot;utf-8&quot;)
        .response(asString)
  
    implicit val backend: SttpBackend[Identity, Nothing, NothingT] = HttpURLConnectionBackend()
    request.send().body
  
    resquest.Response match {
      case Success(value) =&gt; {
          val src = new PrintWriter(new File(filename))
          src.write(value.toString)
          src.close()
        }
      case Failure(exception) =&gt; log error
    }
  
  </code></pre>
  <p>when i execute the program sequentially, it work as expected,
  if i tried to run parallel, by changing <code>ZIO.foreach</code> to <code>ZIO.foreachPar</code>.
  The program is terminating prematurely, i get that, i'm missing something basic here,
  any help is appreciated to help me figure out the issue.</p>