[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-java
Subject: Graphics.drawString)() bug ?
From: Rob Nugent <r.nugent () unikix ! com>
Date: 1998-05-27 14:36:07
[Download RAW message or body]
Hi,
I am finding that I am getting exceptions when I have multiple threads
using the drawString() method
in the Graphics class. This is using RedHat Linux 5.0 and JDK 1.1.5v7
(libc5).
Take the following short testcase which creates 5 threads each of which
creates an off-screen image
and does drawString() calls.
--------------snip---------------------
import java.awt.*;
public class Draw implements Runnable
{
private static Frame f;
public static void main(String[] argv)
{
f = new Frame("Test Frame");
f.setSize(300,30);
f.setVisible(true);
for (int i = 0; i < 4; i++)
{
Draw d = new Draw();
Thread t = new Thread(d);
t.setDaemon(true);
t.start();
}
}
public void run()
{
System.out.println("Starting");
Image i = f.createImage(200,20);
Graphics g = i.getGraphics();
while (true)
{
g.drawString("0123456789",10,10);
}
}
}
--------------snip---------------------
After a little while of running, I get exceptions as follows:
java.lang.ArrayIndexOutOfBoundsException: 10
at
at sun.awt.motif.X11Graphics.drawMFChars(X11Graphics.java:249)
at sun.awt.motif.X11Graphics.drawChars(X11Graphics.java:217)
at sun.awt.motif.X11Graphics.drawString(X11Graphics.java:210)
at Draw.run(Draw.java:33)
at java.lang.Thread.run(Thread.java)
Note that it has walked off the end of the 10 char String.
It looks to me like something in sun.awt.motif isn't thread safe.
Does anyone have any comments ?
Might this be because libc5 isn't thread safe ? (I can't get the glibc
version to run properly, but the
errors do not occur on JDK1.1.6 on NT.
Can anyone confirm if this occurs or not on Solaris ?
Thanks !
Rob
--
Rob Nugent
Development Manager
UniKix Technologies Europe
r.nugent@unikix.com
Tel: +44 (0) 1489 585503
Fax: +44 (0) 1489 881363
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic