Skip to content

Competitive access to running variable in DefaultClock #20

@darrivau

Description

@darrivau

The "running" variable of DefaultClock is changed by the main thread through "start()", "pause()" or "resume()" and read by the timer thread through "run()". In the "run()" method, the timer thread caches the variable state and even if the main thread do change its value, the timer thread can keep the wrong one in its cache.
To avoid this problem just add "volatile" attribute to the "running" variable :

public class DefaultClock extends Clock implements Runnable{
volatile boolean running;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions