这是matlab中的竞争条件吗?

时间:2015-08-06 22:45:33

标签: matlab user-interface race-condition

标题说明了一切。我想知道以下代码是否容易出现竞争状态。

classdef Foo < handle
    properties
        value = true
    end

    methods
        function toggle(o, ~, ~)
            o.value = ~o.value;
        end
    end
end

function main
    foo = Foo;
    uicontrol('style', 'pushbutton', 'callback',@foo.toggle);
    drawnow

    %// Endless loop which gets broken up by a button press
    while foo.value
        pause(1)
    end

    %// What happens if I press the button twice, really fast? There
    %// is no external function called between here and the previous
    %// while loop.
    if foo.value
        error('Race')
    else
        fprintf('\nWe made it\n')
    end

我是否因为一切都在事件发送线程中发生而从竞争状态中解脱出来?如果我使用按钮的InterruptibleBusyAction属性,是否仍然如此?我发现matlab help非常令人困惑。

如果重要的话我使用R2012a。

0 个答案:

没有答案
相关问题