使用 Applet-Servlet 通信处理大数据时出现问题
我有一个向 Servlet 发出请求的 Applet。在 servlet 上,它使用 PrintWriter 将响应写回到 Applet:
out.println("Field1|Field2|Field3|Field4|Field5......|Field10");
大约有 15000 条记录,因此 out.println() 被执行大约 15000 次。
问题是,当 Applet 收到 Servlet 的响应时,需要大约 15 分钟来处理记录。 我放置了 System.out.println,处理在 5000 左右暂停,然后 15 分钟后继续处理,然后完成。
有人遇到过类似的问题吗? Servlet 的执行时间大约为 2 秒。看来浏览器/小程序处理记录的速度太慢了。
这是小程序代码。有时它只在第一个 System.out 上停止,有时在第二个 System.out 上停止。
while ((line = in.readLine()) != null) {
System.out.println("Reading from stream....");
datavector.add(line);
System.out.println("Vector size="+datavector.size()+" Line added="+line);
}
任何想法表示赞赏。
谢谢。
I have an Applet that makes a request to a Servlet. On the servlet it's using the PrintWriter to write the response back to Applet:
out.println("Field1|Field2|Field3|Field4|Field5......|Field10");
There are about 15000 records, so the out.println() gets executed about 15000 times.
Problem is that when the Applet gets the response from Servlet it takes about 15 minutes to process the records.
I placed System.out.println's and processing is paused at around 5000, then after 15 minutes it continues processing and then its done.
Has anyone faced a similar problem? The servlet takes about 2 seconds to execute. So seems that the browser/Applet is too slow to process the records.
This is the Applet code. Sometimes it just stops on the first System.out and sometimes stops on the second System.out.
while ((line = in.readLine()) != null) {
System.out.println("Reading from stream....");
datavector.add(line);
System.out.println("Vector size="+datavector.size()+" Line added="+line);
}
Any ideas appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题是否与“处理大约 5000 条记录暂停,然后在 15 条记录后自行开始”相关?或者您的小程序上的处理速度很慢
如果您发布一些代码片段,将会有帮助吗?
Is you question related to "processing being paused around 5000 records and then starts on its own after 15" ? OR it is processing being slow on your applet
It will be helpful if you code post some code snippet?
从
while
循环中删除System.out.println()
行。您每个 saldo 调用System.out.println()
30,000 次。这会增加大量开销。如果需要,只需在while
循环之前和之后放置一个即可。Remove the
System.out.println()
lines from thewhile
loop. You're per saldo callingSystem.out.println()
30,000 times. That would add much overhead. Just place one before and one after thewhile
loop if you want.