r/learnjava • u/BrainThinkerMan • 13h ago
threads, concurrency & coroutines queston (beginner)
I am a man whom used kotlin before java, (maybe shoking)
i switched to java for springboot
i knew (a little) about coroutines from kotlin, == multiple things can be done and threads dont block
is the same concept true for java? or does java have some legacy stuff in place of kotlin coroutines?
i see that java has. a thread sleep. method. i dont think kotlin has
long story short, id like to reaffirm my knowledge on concurrency and general and how it
works, and find gaps, ill briefly explain how i think it works, id love for feedback, but you dont need to you can just respond to post that resonate more with you, thank you if anyone does respond
here it is:
concurrency means IO functions can happen without blocking things that come after them
all those functions happen on a thread, and multiple functions can happen on a thread
if it blocks the thread( i think functions other than IO can block aswell) then you can use concurrency that returns a result immediately, -> waits for REAL response -> then jumps back on a thread, -> causing no blocking
now what is thread sleep? and why would i want a thread to sleep?