Skip to content

Commit 6147112

Browse files
committed
Update talk.java
1 parent 939692f commit 6147112

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/tinystruct/examples/talk.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,14 @@ public final String update(final String sessionId) throws ApplicationException,
105105
Builder message;
106106
Queue<Builder> messages;
107107
synchronized (this.list) {
108-
do {
108+
messages = this.list.get(sessionId);
109+
while((message = messages.poll()) == null) {
109110
try {
110111
this.list.wait(TIMEOUT);
111112
} catch (InterruptedException e) {
112113
throw new ApplicationException(e.getMessage(), e);
113114
}
114-
} while((messages = this.list.get(sessionId)) == null || (message = messages.poll()) == null);
115+
}
115116

116117
return message.toString();
117118
}
@@ -144,12 +145,12 @@ private final void copy(Object meetingCode, Builder builder) {
144145
}
145146
}
146147
}
147-
148+
148149
@Override
149150
public String version() {
150151
return "Welcome to use tinystruct 2.0";
151152
}
152-
153+
153154
public static void main(String[] args) throws ApplicationException {
154155
talk talk = new talk();
155156
talk.meetings.put("[M001]", new ConcurrentLinkedQueue<Builder>());
@@ -161,12 +162,12 @@ public static void main(String[] args) throws ApplicationException {
161162
sess.add("{B}");
162163
talk.sessions.put("[M001]", sess);
163164
ApplicationManager.install(talk);
164-
165+
final int n = 1000;
165166
new Thread(new Runnable(){
166167
@Override
167168
public void run() {
168169
int i=0;
169-
while(i++<200)
170+
while(i++<n)
170171
try {
171172
ApplicationManager.call("talk/save/[M001]/{A}/A post "+i, null);
172173
Thread.sleep(1);
@@ -184,7 +185,7 @@ public void run() {
184185
@Override
185186
public void run() {
186187
int i=0;
187-
while(i++<200)
188+
while(i++<n)
188189
try {
189190
ApplicationManager.call("talk/save/[M001]/{B}/B post "+i, null);
190191
Thread.sleep(1);

0 commit comments

Comments
 (0)