Skip to content

Conversation

@jusang3057
Copy link
Owner

delay를 사용하여 10ms마다 숫자를 증가하고 업데이트 하려하였는데,
왠지 모르게 기존의 스톱워치보다 느리게 작동하여 System.currentTimeMillis()을 사용하여 정확한 스톱워치를 만들었음

실습5
2024-12-02
202024-12-02
2024 12 23
2024 12 23
2024 12 30
2025 01 06
2025 01 13
Copy link

@skdud0629 skdud0629 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨어요!

}
else {
Toast.makeText(this, "오류", Toast.LENGTH_SHORT).show()
if (!running) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if else 문으로 안 하고 if문을 두 번 쓴 이유가 있을까요?


private fun startTimer(){
stime = System.currentTimeMillis()
timer = CoroutineScope(Dispatchers.Main).launch {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lifecycleScope을 사용하는 것이 더 안전합니다.

stime = System.currentTimeMillis()
timer = CoroutineScope(Dispatchers.Main).launch {
while(true){
delay(5)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

딜레이를 하는 이유가 있을까용??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants