Wish Server runnable class

Daestrum

Expert
Licensed User
Longtime User
Don't think you'd need a new class as it's quite simple to spawn threads.
B4X:
public static void playAsTask(String s){
        final String ss = s;
        Task task = new Task<Void>() {
                @Override public Void call(){
                       Player player = new Player();
                       player.play(ss);
                       return null;
                 }
        };
        new Thread(task).start();
}
 

Daestrum

Expert
Licensed User
Longtime User
It was not the best example, I just cut/pasted from a program I wrote.
The main parts are
B4X:
 Task task = new Task<Void>() {        <<< a void Task ie it returns nothing to the caller
     @Override public Void call(){
     // do what you need to here
     return null;                                     <<< even though it returns nothing you must return a null
 };
 new Thread(task).start();                     <<< this starts the thread running
 

Roycefer

Well-Known Member
Licensed User
Longtime User
Have you looked at Informatix' CallSubExtended? It allows you to run methods asynchronously, in another thread.
 

LucaMs

Expert
Licensed User
Longtime User
Have you looked at Informatix' CallSubExtended? It allows you to run methods asynchronously, in another thread.

I don't think it can be useful to get what I need.

I need something like "all this code (which could be a "class") must run in its own thread". Almost as it was a project inside a project.
A "multi-room" chat could be an example. Each room should work in its own thread (and it should "communicate" with other threads, but for this I think that thread safe maps should be enough or, at least, I could write something on disk or database).


Thank you, @Roycefer
 

LucaMs

Expert
Licensed User
Longtime User
Last edited:

LucaMs

Expert
Licensed User
Longtime User
waiting-skeleton-55171fb23cefd.jpg


:D:D:D
 
Top