---
title: "Comment by sammo90 on \"Synchronisation and Concurrent Access in Cats Effect 3 [Part 7]\" | Hashnode"
description: "Function \"accessWashroom\" currentTime code is incomplete. Something like: def accessWashroom(person: String, sem: Semaphore[IO]): IO[Unit] = for { t0 &lt;- IO(S"
url: "https://hashnode.com/posts/synchronisation-and-concurrent-access-in-cats-effect-3-part-7/628eab0143220290a7eeb6da/comment/6a081d8c5adec46063438ac2"
---

[Discussion](https://hashnode.com/posts/synchronisation-and-concurrent-access-in-cats-effect-3-part-7/628eab0143220290a7eeb6da)

Comment [Synchronisation and Concurrent Access in Cats Effect 3 \[Part 7\]](https://hashnode.com/posts/synchronisation-and-concurrent-access-in-cats-effect-3-part-7/628eab0143220290a7eeb6da)

[sammo90](https://hashnode.com/@sammo90)

[May 16](https://hashnode.com/posts/synchronisation-and-concurrent-access-in-cats-effect-3-part-7/628eab0143220290a7eeb6da/comment/6a081d8c5adec46063438ac2)

Function "accessWashroom" currentTime code is incomplete. Something like:

```
  def accessWashroom(person: String, sem: Semaphore[IO]): IO[Unit] = for {
    t0  <- IO(System.currentTimeMillis())
    _   <- IO(s"[+ 0 ms] $person wants to access the washroom, waiting for getting the access").trace
    _   <- sem.acquire
    t1  <- IO(System.currentTimeMillis())
    _   <- IO(s"[+ \({t1 - t0} ms] \)person got access to washroom and using it now").trace
    _   <- IO.sleep(5.second)
    t2  <- IO(System.currentTimeMillis())
    _   <- IO(s"[+ \({t2 - t0} ms] \)person left the washroom").trace
    _   <- sem.release
  } yield ()
```

does the job.
