{"action":"created","issue":{"url":"https://api.github.com/repos/NetLogo/NetLogo/issues/876","labels_url":"https://api.github.com/repos/NetLogo/NetLogo/issues/876/labels{/name}","comments_url":"https://api.github.com/repos/NetLogo/NetLogo/issues/876/comments","events_url":"https://api.github.com/repos/NetLogo/NetLogo/issues/876/events","html_url":"https://github.com/NetLogo/NetLogo/issues/876","id":114781549,"number":876,"title":"Pending threads after headless execution","user":{"login":"romainreuillon","id":1270995,"avatar_url":"https://avatars.githubusercontent.com/u/1270995?v=3","gravatar_id":"","url":"https://api.github.com/users/romainreuillon","html_url":"https://github.com/romainreuillon","followers_url":"https://api.github.com/users/romainreuillon/followers","following_url":"https://api.github.com/users/romainreuillon/following{/other_user}","gists_url":"https://api.github.com/users/romainreuillon/gists{/gist_id}","starred_url":"https://api.github.com/users/romainreuillon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romainreuillon/subscriptions","organizations_url":"https://api.github.com/users/romainreuillon/orgs","repos_url":"https://api.github.com/users/romainreuillon/repos","events_url":"https://api.github.com/users/romainreuillon/events{/privacy}","received_events_url":"https://api.github.com/users/romainreuillon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-11-03T10:08:10Z","updated_at":"2015-11-04T18:38:01Z","closed_at":"2015-11-04T18:31:25Z","body":"OpenMOLE calls the headless version of netlogo 5.2: https://github.com/openmole/openmole/blob/master/openmole/plugins/org.openmole.plugin.task.netlogo/src/main/scala/org/openmole/plugin/task/netlogo/NetLogoTask.scala\r\n\r\nIt needs to execute many executions of several netlogo models in various threads. The netlogo headless workspace is created using:\r\n```java\r\n    protected HeadlessWorkspace workspace = HeadlessWorkspace.newInstance();\r\n\r\n    @Override\r\n    public void open(String script) throws Exception {\r\n        workspace.open(script);\r\n    }\r\n```\r\n\r\nAt the end of the execution the workspace is disposed:\r\n```java\r\n    @Override\r\n    public void dispose() throws Exception {\r\n        workspace.dispose();\r\n    }\r\n```\r\n\r\nHowever after many execution there are thousands of threads like that, remaining in the JVM:\r\n```\r\n\"JobThread\" #41890 daemon prio=4 os_prio=0 tid=0x00007f21ee2d5800 nid=0xc2a2 in Object.wait() [0x00007f1d3bdcf000]\r\n   java.lang.Thread.State: TIMED_WAITING (on object monitor)\r\n        at java.lang.Object.wait(Native Method)\r\n        at org.nlogo.job.JobThread$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(JobThread.scala:87)\r\n        at org.nlogo.job.JobThread$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply(JobThread.scala:87)\r\n        at org.nlogo.job.JobThread$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply(JobThread.scala:87)\r\n        at scala.util.control.Exception$Catch.apply(Exception.scala:88)\r\n        at org.nlogo.util.Exceptions$.ignoring(Exceptions.scala:38)\r\n        at org.nlogo.job.JobThread$$anonfun$run$1.apply$mcV$sp(JobThread.scala:84)\r\n        - locked <0x00000000e7eb44d0> (a java.lang.Object)\r\n        at org.nlogo.job.JobThread$$anonfun$run$1.apply(JobThread.scala:76)\r\n        at org.nlogo.job.JobThread$$anonfun$run$1.apply(JobThread.scala:76)\r\n        at scala.util.control.Exception$Catch.apply(Exception.scala:88)\r\n        at org.nlogo.util.Exceptions$.handling(Exceptions.scala:41)\r\n        at org.nlogo.job.JobThread.run(JobThread.scala:75) \r\n```\r\n\r\nHow would it be possible to get a clean state after a NetLogo execution?\r\n\r\nCheers,\r\nRomain\r\n"},"comment":{"url":"https://api.github.com/repos/NetLogo/NetLogo/issues/comments/153823474","html_url":"https://github.com/NetLogo/NetLogo/issues/876#issuecomment-153823474","issue_url":"https://api.github.com/repos/NetLogo/NetLogo/issues/876","id":153823474,"user":{"login":"SethTisue","id":161079,"avatar_url":"https://avatars.githubusercontent.com/u/161079?v=3","gravatar_id":"","url":"https://api.github.com/users/SethTisue","html_url":"https://github.com/SethTisue","followers_url":"https://api.github.com/users/SethTisue/followers","following_url":"https://api.github.com/users/SethTisue/following{/other_user}","gists_url":"https://api.github.com/users/SethTisue/gists{/gist_id}","starred_url":"https://api.github.com/users/SethTisue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SethTisue/subscriptions","organizations_url":"https://api.github.com/users/SethTisue/orgs","repos_url":"https://api.github.com/users/SethTisue/repos","events_url":"https://api.github.com/users/SethTisue/events{/privacy}","received_events_url":"https://api.github.com/users/SethTisue/received_events","type":"User","site_admin":false},"created_at":"2015-11-04T18:38:01Z","updated_at":"2015-11-04T18:38:01Z","body":"np, glad I could help you narrow it down."}}