-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1, 1.1.5
-
None
-
x86
-
windows_95
Name: sgC58550 Date: 03/14/97
To repeat the problem, run the applet and hit the SEND button several
times to start many threads. We have seen it lock up when the SEND
button was hit only once (i.e. 2 new threads) but it happens much faster
when the SEND button is hit several times.
import java.applet.*;
import java.awt.*;
public class AppletClient extends Applet
{
static Frame f = new Frame();
static TextArea ta = new TextArea(5, 75);
public void init()
{
setLayout(new BorderLayout());
add("North", new Button("SEND"));
f.setLayout(new BorderLayout());
f.add("Center", ta);
f.resize(300, 400);
f.setBackground(Color.green);
f.show();
}
public boolean action(Event evt, Object arg)
{
if (arg.equals("SEND"))
{
Displayer ac1 = new Displayer("Argentina", this);
Displayer ac2 = new Displayer("Ethiopia", this);
ac1.start();
ac2.start();
}
else return super.action(evt, arg);
return true;
}
public synchronized void DisplayResults(String name, Thread t)
// public void DisplayResults(String name, Thread t)
{
for (int i=1; i <= 5; i++)
{
ta.appendText("i="+i+" "+name+" "+t.toString() +"\n");
t.yield();
}
}
}
class Displayer extends Thread
{
private String name;
AppletClient a;
public Displayer(String n, AppletClient caller)
{
name = n;
a = caller;
}
public void run()
{
for (;;) {
a.DisplayResults(name, this);
try { sleep(2000); } catch (InterruptedException e) {}
}
}
}
--
======================================================================
To repeat the problem, run the applet and hit the SEND button several
times to start many threads. We have seen it lock up when the SEND
button was hit only once (i.e. 2 new threads) but it happens much faster
when the SEND button is hit several times.
import java.applet.*;
import java.awt.*;
public class AppletClient extends Applet
{
static Frame f = new Frame();
static TextArea ta = new TextArea(5, 75);
public void init()
{
setLayout(new BorderLayout());
add("North", new Button("SEND"));
f.setLayout(new BorderLayout());
f.add("Center", ta);
f.resize(300, 400);
f.setBackground(Color.green);
f.show();
}
public boolean action(Event evt, Object arg)
{
if (arg.equals("SEND"))
{
Displayer ac1 = new Displayer("Argentina", this);
Displayer ac2 = new Displayer("Ethiopia", this);
ac1.start();
ac2.start();
}
else return super.action(evt, arg);
return true;
}
public synchronized void DisplayResults(String name, Thread t)
// public void DisplayResults(String name, Thread t)
{
for (int i=1; i <= 5; i++)
{
ta.appendText("i="+i+" "+name+" "+t.toString() +"\n");
t.yield();
}
}
}
class Displayer extends Thread
{
private String name;
AppletClient a;
public Displayer(String n, AppletClient caller)
{
name = n;
a = caller;
}
public void run()
{
for (;;) {
a.DisplayResults(name, this);
try { sleep(2000); } catch (InterruptedException e) {}
}
}
}
--
======================================================================
- duplicates
-
JDK-4080391 TextArea.setText() doesn't work for large Strings.
-
- Closed
-