T
toton
Hi,
I have a custom control, (extended from JComponent) which also
implements MouseListener and MouseMotionListener & Runnable (or can
have a seperate Runnable implementation also).
Say the run method generates a set of random number (actually it do
something more) and store them in a GeneralPath member field named
path. It also stores it in another member field named GeneralPath
allPath .
Now what I want when mousePressed event occures it clears the the path
(but not allPath) and starts the thread. The thread in turn adds a
random point on the path. then yield , repaint ,sleep for 5 ms.
when the mosueReleaseed occures, it makes the thread null. Now the
thread to all a point to the path (and allPath) only when mouse is
pressed. thus I store mousePressed field in a volatile boolean and
check for it before adding.
allPath purely stores all of the random points , while path to store
random points between a mousePressed & mouseRealeased.
Now, I am experiencing some threading problem . what other
synchronization is needed ? I am doubtfull on mouse realease I make the
thread null, and immediately use mousepress what happens?
I have a custom control, (extended from JComponent) which also
implements MouseListener and MouseMotionListener & Runnable (or can
have a seperate Runnable implementation also).
Say the run method generates a set of random number (actually it do
something more) and store them in a GeneralPath member field named
path. It also stores it in another member field named GeneralPath
allPath .
Now what I want when mousePressed event occures it clears the the path
(but not allPath) and starts the thread. The thread in turn adds a
random point on the path. then yield , repaint ,sleep for 5 ms.
when the mosueReleaseed occures, it makes the thread null. Now the
thread to all a point to the path (and allPath) only when mouse is
pressed. thus I store mousePressed field in a volatile boolean and
check for it before adding.
allPath purely stores all of the random points , while path to store
random points between a mousePressed & mouseRealeased.
Now, I am experiencing some threading problem . what other
synchronization is needed ? I am doubtfull on mouse realease I make the
thread null, and immediately use mousepress what happens?