tag:blogger.com,1999:blog-7677021887363364182.post8140192782891922341..comments2023-10-23T11:19:46.090-07:00Comments on Tobe expressed: Is synchronisation expensive? Is that the right question?tobehttp://www.blogger.com/profile/00792674914237130365noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-7677021887363364182.post-8036530380718284132008-03-06T06:14:00.000-08:002008-03-06T06:14:00.000-08:00The bug is that lineNumber[0] may not necessarily ...The bug is that lineNumber[0] may not necessarily be at the proper increment when invokeLater is invoked (because it is non-blocking). Assuming this sort of algorithm is *absolutely* necessary, there are two solutions. Number one, create a final field within the while scope which is assigned to the value of the counter on each loop. Alternatively, invokeAndWait may be used. Stylistically, I tend to prefer the final inner field, but either will work.Daniel Spiewakhttps://www.blogger.com/profile/17323566514229790079noreply@blogger.com