handling-collections-concurrency-in-kotlin/ #210
Replies: 4 comments 1 reply
-
|
백엔드에서는 코루틴을 잘 안쓴다고 생각해서 개념만 알고 넘어갔는데 제대로 공부해봐야겠네요~ |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
후디 행님 항상 응원합니다 ㅎㅎ 요즘 뭐하고 지내나 궁금하네 ~~ |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
글을 너무 잘쓰세요~ 이해가 쉽게 되네요. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
한가지 개선한다면, runBlocking(Dispatchers.Default) {
userIds.forEach { userId ->
launch {
synchronized(users) {
users.add(userClient.getUserById(userId))
}
}
}
}여기서 유저의 정보를 가져오는 API인 I/O 작업은 비동기로 처리하고, users 에 삽입하는 부분만 동기화하면 나을거 같네요. 그렇지 않으면 lock 을 획득한 상태에서 비동기 작업 동안에 블로킹되면서 다른 코루틴들도 다같이 중단되버리지 않을까요? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
handling-collections-concurrency-in-kotlin/
https://hudi.blog/handling-collections-concurrency-in-kotlin/
Beta Was this translation helpful? Give feedback.
All reactions