@@ -47,7 +47,7 @@ Run the following code:
4747import kotlinx.coroutines.*
4848
4949fun main () {
50- GlobalScope .launch { // launch new coroutine in background and continue
50+ GlobalScope .launch { // launch a new coroutine in background and continue
5151 delay(1000L ) // non-blocking delay for 1 second (default time unit is ms)
5252 println (" World!" ) // print after delay
5353 }
@@ -58,7 +58,7 @@ fun main() {
5858
5959</div >
6060
61- > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-01.kt )
61+ > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-01.kt ) .
6262
6363You will see the following result:
6464
@@ -98,7 +98,7 @@ Let's be explicit about blocking using [runBlocking] coroutine builder:
9898import kotlinx.coroutines.*
9999
100100fun main () {
101- GlobalScope .launch { // launch new coroutine in background and continue
101+ GlobalScope .launch { // launch a new coroutine in background and continue
102102 delay(1000L )
103103 println (" World!" )
104104 }
@@ -111,7 +111,7 @@ fun main() {
111111
112112</div >
113113
114- > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-02.kt )
114+ > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-02.kt ) .
115115
116116<!-- - TEST
117117Hello,
@@ -130,7 +130,7 @@ the execution of the main function:
130130import kotlinx.coroutines.*
131131
132132fun main () = runBlocking<Unit > { // start main coroutine
133- GlobalScope .launch { // launch new coroutine in background and continue
133+ GlobalScope .launch { // launch a new coroutine in background and continue
134134 delay(1000L )
135135 println (" World!" )
136136 }
@@ -141,7 +141,7 @@ fun main() = runBlocking<Unit> { // start main coroutine
141141
142142</div >
143143
144- > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-02b.kt )
144+ > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-02b.kt ) .
145145
146146<!-- - TEST
147147Hello,
@@ -184,7 +184,7 @@ import kotlinx.coroutines.*
184184
185185fun main () = runBlocking {
186186// sampleStart
187- val job = GlobalScope .launch { // launch new coroutine and keep a reference to its Job
187+ val job = GlobalScope .launch { // launch a new coroutine and keep a reference to its Job
188188 delay(1000L )
189189 println (" World!" )
190190 }
@@ -196,7 +196,7 @@ fun main() = runBlocking {
196196
197197</div >
198198
199- > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-03.kt )
199+ > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-03.kt ) .
200200
201201<!-- - TEST
202202Hello,
@@ -231,7 +231,7 @@ in its scope complete. Thus, we can make our example simpler:
231231import kotlinx.coroutines.*
232232
233233fun main () = runBlocking { // this: CoroutineScope
234- launch { // launch new coroutine in the scope of runBlocking
234+ launch { // launch a new coroutine in the scope of runBlocking
235235 delay(1000L )
236236 println (" World!" )
237237 }
@@ -241,7 +241,7 @@ fun main() = runBlocking { // this: CoroutineScope
241241
242242</div >
243243
244- > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-03s.kt )
244+ > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-03s.kt ) .
245245
246246<!-- - TEST
247247Hello,
@@ -272,16 +272,16 @@ fun main() = runBlocking { // this: CoroutineScope
272272 }
273273
274274 delay(100L )
275- println (" Task from coroutine scope" ) // This line will be printed before nested launch
275+ println (" Task from coroutine scope" ) // This line will be printed before the nested launch
276276 }
277277
278- println (" Coroutine scope is over" ) // This line is not printed until nested launch completes
278+ println (" Coroutine scope is over" ) // This line is not printed until the nested launch completes
279279}
280280```
281281
282282</div >
283283
284- > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-04.kt )
284+ > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-04.kt ) .
285285
286286<!-- - TEST
287287Task from coroutine scope
@@ -317,7 +317,7 @@ suspend fun doWorld() {
317317
318318</div >
319319
320- > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-05.kt )
320+ > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-05.kt ) .
321321
322322<!-- - TEST
323323Hello,
@@ -328,10 +328,10 @@ World!
328328But what if the extracted function contains a coroutine builder which is invoked on the current scope?
329329In this case ` suspend ` modifier on the extracted function is not enough. Making ` doWorld ` extension
330330method on ` CoroutineScope ` is one of the solutions, but it may not always be applicable as it does not make API clearer.
331- Idiomatic solution is to have either explicit ` CoroutineScope ` as a field in a class containing target function
332- or implicit when outer class implements ` CoroutineScope ` .
331+ The idiomatic solution is to have either an explicit ` CoroutineScope ` as a field in a class containing the target function
332+ or an implicit one when the outer class implements ` CoroutineScope ` .
333333As a last resort, [ CoroutineScope(coroutineContext)] [ CoroutineScope() ] can be used, but such approach is structurally unsafe
334- because you no longer have control on the scope this method is executed . Only private API can use this builder.
334+ because you no longer have control on the scope of execution of this method . Only private APIs can use this builder.
335335
336336### Coroutines ARE light-weight
337337
@@ -354,7 +354,7 @@ fun main() = runBlocking {
354354
355355</div >
356356
357- > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-06.kt )
357+ > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-06.kt ) .
358358
359359<!-- - TEST lines.size == 1 && lines[0] == ".".repeat(100_000) -->
360360
@@ -386,7 +386,7 @@ fun main() = runBlocking {
386386
387387</div >
388388
389- > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-07.kt )
389+ > You can get full code [ here] ( ../kotlinx-coroutines-core/jvm/test/guide/example-basic-07.kt ) .
390390
391391You can run and see that it prints three lines and terminates:
392392
0 commit comments