Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Working with different threads in SWT

Hi Tom

I am sorry for bothering you with my questions , but i simply don't understand where do i post the code , i got to this link http://dev.eclipse.org/newslists/news.eclipse.platform.swt/maillist.html , i searched a little through the site but there is not such options as post , or open theme. Regarding the question the thread spawning is done in the main thread , here is the runnable class , which is  launched asynchrony.


import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;

class Rotate implements Runnable
{
    private Image image;
    private Composite comp;

    public Rotate(Image image, Composite comp) {
        this.image = image;
        this.comp = comp;
    }
    public void run()
    {
        Rectangle rect = comp.getBounds();
        try{
            for (int i = 0 ; i <= rect.width / 2 ; i++)
            {
                comp.setBounds(rect.x + i, rect.y , rect.width - i*2 , rect.height);
                Thread.sleep(1);
                
            }
            for (int i = rect.width / 2 - 1 ; i >= 0  ; i--)
            {
                comp.setBounds(rect.x + i , rect.y , rect.width - i*2 , rect.height);
                Thread.sleep (1);
            }
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
        comp.setBackgroundImage(image);
    }

}

Sie konnen mir auch auf Deutsch antworten.
Vielen Dank im Vorraus!

Roman

On 3/25/07, Tom Schindl <tom.schindl@xxxxxxxxxxxxxxx> wrote:
Hi,

Please post the code you are running and the question to the
platform.swt newsgroup. I suppose you are doing all the thread spawing,
... in the runnable which is simply wrong. You should the only lines of
code you should run in the Runnable are the calls to the SWT-Functions.

Tom

Roman Kournjaev schrieb:
> Hello
>
> I have some synchronization problem , I would very appreciate it if one
> of you could help me out.
>
> I have a class that implements Runnable interface , this class is doing
> some manipulations(for instance setBounds) on a Comosite object from SWT
> , that is connected to some Shell. I am starting two such Threads with
> the Display.getDefault().asyncExec(runnalbe) function (every Threads
> gets a different Composite object) , but The threads are not executed in
> an asynchrony way ,  the first thread is waiting for the other to die
> and only then it starts its actual execution. (sleeping and yielding
> inside the thread didn't help).
>
> Thanks in advance for your help
>
> Roman
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> platform-swt-dev mailing list
> platform-swt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top