local Luan = require "luan:Luan.luan" local error = Luan.error local Table = require "luan:Table.luan" local java_to_table_shallow = Table.java_to_table_shallow or error() local Io = require "luan:Io.luan" local Time = require "luan:Time.luan" local Table = require "luan:Table.luan" local to_table = Table.java_to_table_shallow or error() local Http = require "luan:http/Http.luan" require "java" local Thread = require "java:java.lang.Thread" local LuanException = require "java:luan.LuanException" return function() Io.stdout = Http.response.text_writer() local threads = Thread.getAllStackTraces() local threads = {} for thread, trace in Luan.pairs(to_table(Thread.getAllStackTraces())) do threads[#threads+1] = { trace = trace string = thread.toString() state = thread.getState() } end %>

Luan Threads

<%=Http.request.headers["host"]%> - <%=Time.format(Time.now())%>

<% local count = 0 for _, thread in Luan.ipairs(threads) do local luan_trace = java_to_table_shallow(LuanException.justLuan(thread.trace)) if #luan_trace > 0 then %>

<%=thread.string%> <%=thread.state%>

<% count = count + 1 end end %>

<%=count%> threads found

<% end