B4J Question Is B4J for desktop App supports Multithreading?

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

For desktop app, suppose I have 2 procedures, I want to run procedure A on thread 1 & procedure B on thread 2, can B4J do this?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The answer to the question in the title is yes. Many things in B4X are done using background threads.

For desktop app, suppose I have 2 procedures, I want to run procedure A on thread 1 & procedure B on thread 2, can B4J do this?
Yes, with the Threading library. The real answer is that you need to provide more information as in most cases there are better options.
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
The answer to the question in the title is yes. Many things in B4X are done using background threads.


Yes, with the Threading library. The real answer is that you need to provide more information as in most cases there are better options.
I thought Threading library is for B4A only.

Let say, there are a 1000 similar tasks, but time to finish each task may not be the same. For ex, to finish task 1 need 10 secs, task 2 need 7 secs, and so on.

I want to divide these tasks into 6 threads. Thread 1 assign to task 1, thread 2 assign to task 2, and so on.

When every threads finished the task, it will look for unfinished tasks, and if it found, it will do the task and repeat again the process until no more unfinished tasks exist.

I think this process can't be done using built in B4X background threads. Or can it?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I thought Threading library is for B4A only.
No, it is Java based and works in B4J.
I think this process can't be done using built in B4X background threads
Probably not. Use Threading or Background Worker. I would use Threading but then I'm biased because I wrote it.
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
No, it is Java based and works in B4J.

Probably not. Use Threading or Background Worker. I would use Threading but then I'm biased because I wrote it.
Thanks for your replied.

Personally, I prefer Background Worker because it is simpler, but I don't know if it's enough for my need.

Yours definitely more advanced. I will study both methods to choose which one.
 
Upvote 0
Top