Goroutines count and id

79 views
Skip to first unread message

Durga Someswararao G

unread,
Jun 30, 2020, 3:35:40 AM6/30/20
to golang-nuts
Hi,
Can some one help for below queries

Is it possible to get goroutine id when we creted?
Is it possible to get goroutines count while we creating?
Is it possible to terminate a goroutine based on ID like if any goroutine has infinite loops?
Is it possible to clean up memory of variable like we have free in C?

Thanks,
Durga SomeswaraRao G.

Jan Mercl

unread,
Jun 30, 2020, 3:50:39 AM6/30/20
to Durga Someswararao G, golang-nuts
On Tue, Jun 30, 2020 at 9:36 AM Durga Someswararao G
<durgasomes...@gmail.com> wrote:

> Is it possible to get goroutine id when we creted?
> Is it possible to get goroutines count while we creating?
> Is it possible to terminate a goroutine based on ID like if any goroutine has infinite loops?
> Is it possible to clean up memory of variable like we have free in C?

The answer to all of the above questions, in the first approximation, is no.

Unsafe tricks may help to achieve some of those goals. What's the
purpose? Is this a XY problem?

Hugo Cornelis

unread,
Jun 30, 2020, 4:50:32 AM6/30/20
to Jan Mercl, Durga Someswararao G, golang-nuts

If you want to identify goroutines at runtime, you can find in the attachments patches for Golang 1.10 to allow to assign a name to a goroutine.

These are patches against Golang 1.10 because I have been using the gccgo runtime that comes with GCC 8.4.

This could help you forward for what you want.

Hugo


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAA40n-ULnCkc7hw0c%3DQCTSAvyP3ZO4rXmTEjm5fb6m2QTJC%3Duw%40mail.gmail.com.
0002-improved-goroutine-name-reporting-wrt-parsing.patch
0001-added-goroutine-naming.patch
Reply all
Reply to author
Forward
0 new messages