(If more than y threads are already doing work when 0 T.y is issued, then the extraneous threads should exit as soon as they are finished; this should be completely transparent. Thread count is a hint; it should not affect semantics except in a buggy program.)

On Thu, 28 Apr 2022, Elijah Stone wrote:

Current interface for creating threads is 0 T.''. I find this interface problematic for a couple of reasons:

1. Pretty much every j script I have seen anyone write is headed by something like 0&T.@''^:n'', where n is the desired number of threads to create. I haven't ever seen anyone call 0 T.'' directly by hand, and I don't think there is ever a good reason to do that. 0&T.@''^:n'' is cumbersome and not particularly clear.

2. There is no mechanism to reduce the number of threads.

3. (This was pointed out by somebody else:) if a script is headed by 0&T.@''^:n'', then every time that script is reloaded, n _new_ threads will be created, which is probably not desirable behaviour.

I therefore suggest that the threading interface be changed so that 0 T.y ensures that there are y threads, creating or destroying threads as needed.

Question: should y be the overall number of threads, or the number of threads on top of the master thread? If the former, should 0 T.0 be punned to exit the session (i.e. kill all threads, including the master thread)?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to