Error:
        Exception in thread "Thread-2200" java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Unknown Source)
        at problem1.solvinging$solver.distancecalculator(Orienteering.java:107)
        at problem1.solveing$solver.run(Orienteering.java:165)
Class:
public void distancecalculator(char [][]problem  , int distancefound) {
    Point p = new Point();
    LinkedList<Point> q = new LinkedList<>();
    q.add(origin);
    int []x = {1,-1,0,0};
    int []y = {0,0,1,-1};
    dist[0][0] = distancefound;
    while(!q.isEmpty()) {
        p = q.getFirst();
        for(int i = 0; i < 4; i++) {
            int a = p.x + x[i];
            int b = p.y + y[i];
            if(a >= 0 && b >= 0 && a < m && b < n && dist[a][b]==2) {
                dist[a][b] = 1 + dist[p.x][p.y] ;
                if(k>0) {
                    solver s = new solver(newproblem,dist[a][b]);
                    new Thread(s).start();
                }
I am getting the above error in my program while executing it
But the program is still running
How i correct it please help me
Thanks in advance.Suggest new edits if required
 
     
     
    