Multithreading in red5

I have a working red5 application and I use MultiThreadedApplicationAdapter, but multithreading does not work. Here is an example that I want to do this so that multiple clients call test () and return without blocking other clients. However, it happened that the second client must wait for the completion of the first client, and then run test (). Any idea how to make this work? Thanks.

public class Application extends MultiThreadedApplicationAdapter { public void test() { System.out.println("test "+System.currentTimeMillis()); try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } } } 

Client-side code is as follows:

 conn.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); conn.connect(server); conn.call("test",null); 
+4
source share
2 answers

Thank you for finding the main error in our socket processing; it did not work as expected with the latest version of Mina (version 2.0.4). I will review the problem later, but for now this is fixed in version 4270

+4
source

The ApplicationAdapter already had a ScheduleJob application for managing multi-threaded processes.

example

 public boolean connect(IConnection conn, IScope scope, Object[] params) { iconn = (IServiceCapableConnection) conn; appScope = scope; createSharedObject(appScope, "thread", false); //updateArray(); this.addScheduledJob(100, new IScheduledJob() { @Override public void execute(ISchedulingService jobs0) throws CloneNotSupportedException { System.out.println(sendList); iconn.invoke("receiveVariable", new Object[] { sendList.toArray() }); sendList.clear(); try { Thread.sleep(5000); updateArray(); } catch (InterruptedException e) { e.printStackTrace(); } } }); return true; } 
0
source

Source: https://habr.com/ru/post/1340931/


All Articles