Skip to content

Concurrency issues at AboutCodeFragments, koan 1, test 3 #17

@anatoliykmetyuk

Description

@anatoliykmetyuk

This test fails from time to time non-deterministically:

[info] AboutCodeFragments:
[info] - Koan 1 *** FAILED ***
[info]   Test 3: 101 was not equal to 201 (KoanSuite.scala:122)

This code:

        q  = {* i=1; Thread.sleep(200); i+=100 *} // 200 ms is enough to "trust" in interleaving

is executed in parallel:

        s3 = reset;  q & q

So here we have two Java threads doing non-atomic operations on the i variable concurrently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions