Skip to content

Commit 4871af6

Browse files
authored
Added a timeout for message updating
1 parent e5c1e7b commit 4871af6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/tinystruct/examples/talk.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ public final String update(final String sessionId) throws ApplicationException,
130130
Queue<Builder> messages = this.list.get(sessionId);
131131
// If there is a new message, then return it directly
132132
if((message = messages.poll()) != null) return message.toString();
133-
while((message = messages.poll()) == null) {
133+
134+
long startTime = System.currentTimeMillis();
135+
while((message = messages.poll()) == null && (System.currentTimeMillis()-startTime) <= 10000) {
134136
;
135137
}
136138
return message.toString();

0 commit comments

Comments
 (0)