Graphical rendering OUTSIDE event thread

I am attempting to build an application that draws to a Canvas OUTSIDE of the AWT event thread. Specifically, I am doing CPU intensive calculations in a native thread and then writing to the Canvas, within this same thread, via the AWT native interface. This produces the desired results.

I am aware that ALL graphical rendering SHOULD be done within the event thread according to basic AWT design policy. What are the side effects or "gotchas" of doing rendering outside of the event thread?

[505 byte] By [garyenge] at [2007-9-27 19:41:01]
# 1

Offhand I'd think the undesired side effect would be uncertainty in whose bits were on the screen. That is, if the component you're drawing to has its own rendering in its paint method, and you're asynchronously drawing to the components area in a separate thread, it may well draw over the top of stuff you've drawn and neither would know the other was drawing.

By "AWT native interface" I assume you mean JAWT?

I recall reading in these forums very recently of someone having difficulties being sure which thread was drawing when in a multithreaded situation.

- David

\

davidherron1 at 2007-7-6 22:56:32 > top of Java-index,Desktop,Core GUI APIs...
# 2

> Offhand I'd think the undesired side effect would be

> uncertainty in whose bits were on the screen. That

> is, if the component you're drawing to has its own

> rendering in its paint method, and you're

> asynchronously drawing to the components area in a

> separate thread, it may well draw over the top of

> stuff you've drawn and neither would know the other

> was drawing.

>

> By "AWT native interface" I assume you mean JAWT?

>

> I recall reading in these forums very recently of

> someone having difficulties being sure which thread

> was drawing when in a multithreaded situation.

>

> - David

> \

That is not a concern in this case. We have a Canvas rendered by the thread outside of the event thread and a JPanel with buttons being rendered by the event thread. "Stepping on each other" is not an issue here.

Gary Engebretson

garyenge at 2007-7-6 22:56:32 > top of Java-index,Desktop,Core GUI APIs...