It would be great to create a class that ran in it's own thread space. I am already familar with the threading abilites in B4J but I think this would be a great addition. The use case I would refer too is when using a socketserver:
B4X:
Private Sub srvr_NewConnection(Successful As Boolean, NewSocket As Socket)
Dim NewClient As cls_sck_client
If Successful Then
NewClient.Initialize(NewSocket)
Else
Log("Connection attempt failed: " & LastException.Message)
End If
srvr.Listen
End Sub
In the above code the cls_sck_client class would run in it's own thread.
Thanks for the reply. cls_sck_client class is using AsyncStreams, but I would rather have the class itself not running on the main thread or in my case an ABBackgroundWorker tread. I am using ABBackgroundWorkers to run the serversocket. My concern is with a high volume of traffic that performance may become an issue. In the cls_sck_client it also uses SQL GetConnection from the main ConnectionPool.