4

I need to get id of the current thread in Dart. Something similar to how I would do this in Java (or C#):

Thread.currentThread().getId()
Wheel Builder
  • 3,515
  • 5
  • 20
  • 32
  • 1
    What problem are you trying to solve? Dart does not have threads, so maybe there is something else you can use to solve the same problem. – lrn May 23 '19 at 09:35

2 Answers2

5

Coming in a bit late but I think Isolate.current.debugName should give you what you're looking for.

Virendra
  • 115
  • 2
  • 10
0

Are you talking about the Process ID of the running program? Because that is possible with the pid property from dart:io:

https://api.dartlang.org/stable/2.3.1/dart-io/pid.html

julemand101
  • 28,470
  • 5
  • 52
  • 48
  • A process can have many threads, I am specifically looking for the current thread id, inside the process – Wheel Builder May 22 '19 at 14:30
  • 1
    @WheelBuilder Dart doesn't expose threads. It uses isolates, which *might* run in a separate thread or in a separate process. https://stackoverflow.com/a/11364519/179715 – jamesdlin May 22 '19 at 16:03
  • You can use the Dart Observatory for debugging: https://dart-lang.github.io/observatory/get-started.html – julemand101 Feb 07 '20 at 14:15