But why doesn't it exit? Is it a scope problem? The value of a is changed in RunnableWrapper, but this can't be seen in Test() ?
Not excactly a scope problem, if you'll print a inside the loop the code will work properly and you'll see the value increases as it should.
a small hint:
The problem comes when a is not involved anywhere within the while statement, so basically the compiler 'thinks' that a will never reach 10 and it changes the statement to the following:
making the code never end.
There's a special keyword that needs to be added to prevent this, nuff hints