Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #1009 (closed enhancement: wontfix)

Opened 17 years ago

Last modified 17 years ago

Let Thread have an interrupt feature like Java

Reported by: keinfarbton Assigned to: sean
Priority: major Milestone: 0.99.6
Component: Core Functionality Version: 0.99.5 Jascha
Keywords: Cc:

Change History

03/28/08 20:27:18 changed by sean

  • status changed from new to closed.
  • resolution set to wontfix.

I've never liked that aspect of Java threads :-) I think this can be done already in Tango and done much better by using the primitives in tango.core.sync than by adding a poor implementation of similar functionality into Thread itself. If there is something specific that you need that tango.core.sync doesn't provide however, please let me know.

03/28/08 20:45:40 changed by keinfarbton

Hm, i don't understand how to make this with other primitives.

I see interrupted as a standardized mechanism, how one thread can send a signal to another thread. They don't need to know anything about each other. And that is the advantage. Sure its possible to implement something for your own threads, but the Java impl works also if the called thread is blocked in a library call. Because the library shall care about this if it blocks somewhere.

What do i miss here?

03/28/08 20:58:28 changed by sean

Well, I suppose I should say that I just don't see the need for interrupt even in Java when Java has wait/notify. From the description, it seems potentially useful for interrupting a thread blocking on a read of an interruptable channel, but that's not something we could easily support in Tango anyway. Basically, I see most uses of interrupt replaced by condition variables and semaphores in Tango. Both place the target thread in an alertable wait condition and let another thread wake the waiting thread via a signal. Are there specific uses of interrupt in Java that don't fit with these primitives?

03/28/08 21:16:53 changed by keinfarbton

What about Thread.sleep()/join()? Interrupt would cause an exception and make it easy to stop the thread.

The main reason why i ask for this is, to be able to port Java code using this functionality.

04/02/08 02:07:21 changed by sean

This functionality isn't built into the OS calls of the same name, so it would have to be faked with semaphores or the like.