---
title: "Discussion on \"Synchronisation and Concurrent Access in Cats Effect 3 [Part 7]\" | Hashnode"
description: "Discussion on \"Synchronisation and Concurrent Access in Cats Effect 3 [Part 7]\". Introduction\nThis is the part 7 of the Cats Effect 3 blog series. In this part, we will be looking at the synchronisation primitives available in CE3.\nSynchronisation and Concurrency\nWhen we have mult"
url: "https://hashnode.com/posts/synchronisation-and-concurrent-access-in-cats-effect-3-part-7/628eab0143220290a7eeb6da"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Synchronisation and Concurrent Access in Cats Effect 3 \[Part 7\]](https://yadukrishnan.live/synchronisation-and-concurrent-access-in-cats-effect-3-part-7?utm_source=hashnode&utm_medium=feed)

Introduction This is the part 7 of the Cats Effect 3 blog series. In this part, we will be looking at the synchronisation primitives available in CE3. Synchronisation and Concurrency When we have mult

May 25, 2022 · 7 min read · yadukrishnan.live  
Updated May 15  
Read the article

-   [#scala](https://hashnode.com/tag/scala)
-   [#concurrency](https://hashnode.com/tag/concurrency)
-   [#functional-programming](https://hashnode.com/tag/functional-programming)

## Written by

[Yadukrishnan](https://hashnode.com/@yadukrishnan)

@yadukrishnan · Hamburg, Germany

  
[View profile](https://hashnode.com/@yadukrishnan)

Software Developer - Scala

Travel | Movies | History | Nature I am a software developer. Started my career as a Java developer, but later switched to Scala. I wish to write Scala articles which are easier for newbies to follow. I love to travel, prefer to be alone or in very small group. Love to watch movies/series.

## Responses 3

Markdown supported · ⌘↵ to post

[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.

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

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

Wouldn't it be better to use

```
_  <- IO.println(...
```

instead of

```
_ = println( ...
```

?

[Yadukrishnan](https://hashnode.com/@yadukrishnan)

[May 15](https://hashnode.com/posts/synchronisation-and-concurrent-access-in-cats-effect-3-part-7/628eab0143220290a7eeb6da/comment/6a0705ceb54b0a065f49b586#reply-6a0735bb73afc887577b7763)

Yes, definitely it is better to use it that way to be more functional. I updated it.
