Runnable 中抛出java.lang.ArrayIndexOutOfBoundsException: -1

[已解决] SimpleDateFormat.format并发调用会有问题private SimpleDateFormat.StringBuffer format(Date date, StringBuffer toAppendTo, FieldDelegate delegate) 里面用了calendar.setTime(date);这玩意是全局的,后面还会调用它,所以并发时候会出问题。
Random中protected Random.next(int bits);采用AtomicLong的CAS操作并发时候不会出问题。


每个Task有自己的ArrayList实例,在多线程情况下每个ArrayList实例应该不存在并发写入啊,为没什么还报ArrayIndexOutOfBoundsException: -1
求助大神,网上找了好久没结果。


import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static java.lang.System.out;

public class TestArrayList {

    public static void main(String[] args){
        TestArrayList t= new TestArrayList();
        t.testInsertRows();
    }

    private static int millisecondOf1Day= 1000*3600*24;
    private static int millisecondOf5Min= 1000*60*5;
    private static final SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private final ExecutorService pool= Executors.newFixedThreadPool(8);

    public void testInsertRows(){
        Random random= new Random();
        int taskId= 0;
        for(int i=0; i< 8; i++){
            taskId++;
            pool.submit(new Task(taskId, 10000, null));
        }
        out.println("all submited!");
    }

    static class Task implements Runnable{
        private Integer id;
        private List<Bean> list;
        private int rowCount;
        private int count=0;
        private Random random;

        public Task(Integer id, Integer rowCount, Random random){
            this.id= id;
            this.list= new ArrayList<>(rowCount+1);
            this.rowCount= rowCount;
//          this.random= random;
            this.random= new Random();
        }

        @Override
        public void run() {
            out.println("task:"+id+" is running! "+Thread.currentThread());
            try{
                for(int j=0; j< rowCount; j++ ){
                    Long randomTime= random.nextLong();
                    Date validityDate= new Date(randomTime- millisecondOf1Day),
                            startDate= new Date(randomTime),
                            endDate= new Date(randomTime+ 2*millisecondOf1Day);
                    Bean bean = new Bean();
                    bean.setField0("K0000033");
                    bean.setField1("0001");
                    bean.setField2(sdf.format(validityDate));
                    bean.setField3(new Double(0.0).toString());
                    bean.setField4(sdf.format(startDate));
                    bean.setField5(sdf.format(endDate));
                    list.add(bean);
                }
                out.println("list is prepared in thread:"+id);
                Thread.sleep(millisecondOf5Min);//
                out.println(count+" rows has been inserted in thread:"+id); 
            }catch (Exception e) {
                synchronized (out) {                    
                    out.println("task:"+id+" in error"+Thread.currentThread());
                    e.printStackTrace();
                    out.println("task:"+id+" error info print completed");
                }
            }
        }
    }

}

class Bean{
    private String field0;
    private String field1;
    private String field2;
    private String field3;
    private String field4;
    private String field5;
    private String field6;
    /**
     * @return the field0
     */
    public String getField0() {
        return field0;
    }
    /**
     * @param field0 the field0 to set
     */
    public void setField0(String field0) {
        this.field0 = field0;
    }
    /**
     * @return the field1
     */
    public String getField1() {
        return field1;
    }
    /**
     * @param field1 the field1 to set
     */
    public void setField1(String field1) {
        this.field1 = field1;
    }
    /**
     * @return the field2
     */
    public String getField2() {
        return field2;
    }
    /**
     * @param field2 the field2 to set
     */
    public void setField2(String field2) {
        this.field2 = field2;
    }
    /**
     * @return the field3
     */
    public String getField3() {
        return field3;
    }
    /**
     * @param field3 the field3 to set
     */
    public void setField3(String field3) {
        this.field3 = field3;
    }
    /**
     * @return the field4
     */
    public String getField4() {
        return field4;
    }
    /**
     * @param field4 the field4 to set
     */
    public void setField4(String field4) {
        this.field4 = field4;
    }
    /**
     * @return the field5
     */
    public String getField5() {
        return field5;
    }
    /**
     * @param field5 the field5 to set
     */
    public void setField5(String field5) {
        this.field5 = field5;
    }
    /**
     * @return the field6
     */
    public String getField6() {
        return field6;
    }
    /**
     * @param field6 the field6 to set
     */
    public void setField6(String field6) {
        this.field6 = field6;
    }
    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "Bean [field0=" + field0 + ", field1=" + field1 + ", field2=" + field2 + ", field3=" + field3
                + ", field4=" + field4 + ", field5=" + field5 + ", field6=" + field6 + "]";
    }
}

task:1 is running! Thread[pool-1-thread-1,5,main]
task:4 is running! Thread[pool-1-thread-4,5,main]
task:3 is running! Thread[pool-1-thread-3,5,main]
task:2 is running! Thread[pool-1-thread-2,5,main]
task:5 is running! Thread[pool-1-thread-5,5,main]
task:6 is running! Thread[pool-1-thread-6,5,main]
all submited!
task:7 is running! Thread[pool-1-thread-7,5,main]
task:8 is running! Thread[pool-1-thread-8,5,main]
task:7 in errorThread[pool-1-thread-7,5,main]
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Calendar.getDisplayName(Unknown Source)
at java.text.SimpleDateFormat.subFormat(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.DateFormat.format(Unknown Source)
at com.haimian.test.concurrent.TestArrayList$Task.run(TestArrayList.java:64)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
task:7 error info print completed
task:8 in errorThread[pool-1-thread-8,5,main]
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Calendar.getDisplayName(Unknown Source)
at java.text.SimpleDateFormat.subFormat(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.DateFormat.format(Unknown Source)
at com.haimian.test.concurrent.TestArrayList$Task.run(TestArrayList.java:65)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
task:8 error info print completed
task:4 in errorThread[pool-1-thread-4,5,main]
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Calendar.getDisplayName(Unknown Source)
at java.text.SimpleDateFormat.subFormat(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.DateFormat.format(Unknown Source)
at com.haimian.test.concurrent.TestArrayList$Task.run(TestArrayList.java:62)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
task:4 error info print completed
task:1 in errorThread[pool-1-thread-1,5,main]
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Calendar.getDisplayName(Unknown Source)
at java.text.SimpleDateFormat.subFormat(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.DateFormat.format(Unknown Source)
at com.haimian.test.concurrent.TestArrayList$Task.run(TestArrayList.java:64)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
task:1 error info print completed
task:5 in errorThread[pool-1-thread-5,5,main]
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Calendar.getDisplayName(Unknown Source)
at java.text.SimpleDateFormat.subFormat(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.DateFormat.format(Unknown Source)
at com.haimian.test.concurrent.TestArrayList$Task.run(TestArrayList.java:65)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
task:5 error info print completed
task:3 in errorThread[pool-1-thread-3,5,main]
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Calendar.getDisplayName(Unknown Source)
at java.text.SimpleDateFormat.subFormat(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.DateFormat.format(Unknown Source)
at com.haimian.test.concurrent.TestArrayList$Task.run(TestArrayList.java:64)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
task:3 error info print completed
task:6 in errorThread[pool-1-thread-6,5,main]
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Calendar.getDisplayName(Unknown Source)
at java.text.SimpleDateFormat.subFormat(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.DateFormat.format(Unknown Source)
at com.haimian.test.concurrent.TestArrayList$Task.run(TestArrayList.java:64)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
task:6 error info print completed
list is prepared in thread:2

yhk1996
needRestart protected Random.next(int bits);采用AtomicLong的CAS操作
大约一年之前 回复
yhk1996
needRestart private SimpleDateFormat.StringBuffer format(Date date, StringBuffer toAppendTo, FieldDelegate delegate) 里面用了calendar.setTime(date);这玩意是全局的估计在这就出毛病了
大约一年之前 回复

2个回答

Random 不要公用,改为线程内新建再试试

yhk1996
needRestart 了解了,之前是看别人也用单例才把random用单例的。原来这个采纳后就不能修改了……
大约一年之前 回复
weixin_39606236
꧁gaoKuo꧂ 回复GaoKuoZ: 看了下文档,我Random也理解错了 java.util.Random的java.util.Random是线程安全的。 但是,跨线程的同时使用java.util.Random实例可能会遇到争用,从而导致性能下降。
大约一年之前 回复
weixin_39606236
꧁gaoKuo꧂ 回复needRestart: 我都没看到sdf.... Random也不要线程共享哦
大约一年之前 回复
yhk1996
needRestart 感谢大佬提醒
大约一年之前 回复
yhk1996
needRestart 破案了……是simpleDateFormat被多线程调用出的错,Random不会出并发错误。之前报错的行数是乱的也一直没注意这个。
大约一年之前 回复
yhk1996
needRestart 是结束
大约一年之前 回复
yhk1996
needRestart 我把cache打印时候加锁了,保证出错时候只有一个线程打印输出,"task:n in error…"是开始,"task:n error info…
大约一年之前 回复
weixin_39606236
꧁gaoKuo꧂ 回复needRestart: 错误信息发一下 全部的
大约一年之前 回复
yhk1996
needRestart 刚试了还是一样的……吐血啊,上Google也搜了,就是没找到相关的。
大约一年之前 回复

线程中用了那么多的成员变量,这种很容易出现线程数据的问题,就好比卖火车票一样,要考虑线程的安全性的

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Kettle连接mysql数据库报错Failed to execute runnable (java.lang.NullPointerException)

Kettle连接mysql数据库点击确认时报错Failed to execute runnable (java.lang.NullPointerException)该怎么办呀 ![图片说明](https://img-ask.csdn.net/upload/202004/24/1587710084_31337.jpg)

springmvc 实现文件下载 出现异常java.lang.OutOfMemoryError: Java heap space

网上找解决方案,一般都是tomcat中添加-Xms256m -Xms512m等配置,但是不行啊。 我的是MyEclipse里的tomcat。 下载20M(包括)以内的文件没问题,超过就会报异常,有什么解决办法吗? 还有是不是请求下载文件时,服务器会把文件全部装入内存再发过来,还是分成多个部分发送,超过内存大小的文件如何发送呢? ** *--异常信息* ** type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.OutOfMemoryError: Java heap space org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1259) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) root cause java.lang.OutOfMemoryError: Java heap space org.apache.commons.io.output.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:324) org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:361) org.apache.commons.io.FileUtils.readFileToByteArray(FileUtils.java:1360) com.ysm.ysite.controller.Test.fileDownload(Test.java:60) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.

java.lang.NoClassDefFoundError 不是环境变量

原码 import java.awt.*; import java.awt.event.*; public class TankClient extends Frame { int x = 50, y = 50; @Override public void paint(Graphics g) { Color c = g.getColor(); g.setColor(Color.RED); g.fillOval(50, 50, 30, 30); y += 5; } public void lauchFrame() { this.setLocation(400, 300); this.setSize(800, 600); this.setTitle("TankWar"); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); this.setResizable(false); this.setBackground(Color.GREEN); setVisible(true); new Thread(new PaintThread()).start(); } public static void main(String[] args) { TankClient tc = new TankClient(); tc.lauchFrame(); } private class PaintThread implements Runnable{ @Override public void run() { repaint(); try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } }} } 问题 Exception in thread "main" java.lang.NoClassDefFoundError: TankClient$PaintThread at TankClient.lauchFrame(TankClient.java:27) at TankClient.main(TankClient.java:32) Caused by: java.lang.ClassNotFoundException: TankClient$PaintThread at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 2 more

mybatis与struts1 [java.lang.NoClassDefFoundError:org/apache/ibatis/io/Resources]

在Action中,当我要向数据库中插入一条记录时,报了下面的错误: [code="java"] javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/ibatis/io/Resources org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:294) org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187) com.zrxx.action.ProjectAction.execute(ProjectAction.java:33) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) java.lang.NoClassDefFoundError: org/apache/ibatis/io/Resources com.zrxx.util.SqlSessionFactoryTool.getSqlSessionFactory(SqlSessionFactoryTool.java:30) com.zrxx.dao.BaseDao.openSession(BaseDao.java:15) com.zrxx.dao.BaseDao.openSession(BaseDao.java:10) com.zrxx.dao.ProjectDao.insertPro(ProjectDao.java:13) com.zrxx.action.ProjectAction.add(ProjectAction.java:54) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270) org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187) com.zrxx.action.ProjectAction.execute(ProjectAction.java:33) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) [/code] 这个错误是当dao对象已经创建了,调用dao.insert()时发出的 附上我的SqlSessionFactoryTool源代码: [code="java"] public class SqlSessionFactoryTool { private static SqlSessionFactoryTool tool; private SqlSessionFactory factory; public static SqlSessionFactoryTool getInstance(){ if(tool == null) tool = new SqlSessionFactoryTool(); return tool; } public SqlSessionFactory getSqlSessionFactory(){ String resource = "/mybatis.xml"; Reader reader = null; try { reader = Resources.getResourceAsReader(resource); } catch (IOException e) { e.printStackTrace(); } factory = new SqlSessionFactoryBuilder().build(reader); return factory; } [/code] 这是我的目录结构 [img]http://dl.iteye.com/upload/attachment/597707/8f659481-6204-34e4-9c24-18ba93290695.png[/img]

java.lang.IllegalArgumentException 错误异常求解

![图片说明](https://img-ask.csdn.net/upload/201605/20/1463708214_581222.png) ![图片说明](https://img-ask.csdn.net/upload/201605/20/1463708232_363541.png) 上面是代码的日志 求大神指点

locked (a java.util.zip.ZStreamRef) 锁不释放,cpu满负载

"llcs-117" prio=10 tid=0x00007f716c15f000 nid=0x267f runnable [0x00007f715338d000] java.lang.Thread.State: RUNNABLE at java.util.zip.Inflater.inflateBytes(Native Method) at java.util.zip.Inflater.inflate(Inflater.java:259) - locked <0x0000000741d9e308> (a java.util.zip.ZStreamRef) at java.util.zip.Inflater.inflate(Inflater.java:280) 都是类似如此的线程,最大值设置了200个,有一半以上的线程是这个状态

Android通过PHP文件连接到数据库E / Buffer错误:转换结果时出错java.lang.NullPointerException:lock == null

<div class="post-text" itemprop="text"> <p>I am trying to develop a museum search app and try to list my php JSON results in a listView but i can not access my JSON results from Android, i will submit my code and the error messages i get:</p> <p>DisplaySearchResultsActivity.java</p> <pre><code>package com.cloudlionheart.museumsearchapplication; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import org.apache.http.NameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.ListActivity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.SimpleAdapter; import android.widget.TextView; public class DisplaySearchResultsActivity extends ListActivity { // Progress Dialog private ProgressDialog pDialog; // Creating JSON Parser object JSONParser jParser = new JSONParser(); ArrayList&lt;HashMap&lt;String, String&gt;&gt; museumItemsList; // url to get all products list private static String url_search_results = "http://192.168.56.1/android_connect/get_all_products.php"; // JSON Node names private static final String TAG_SUCCESS = "success"; private static final String TAG_MUSEUM_ITEMS = "museum_items"; private static final String TAG_MUSEUM_ITEM_ID = "museum_item_id"; private static final String TAG_MUSEUM_ITEM_NAME = "museum_item_name"; private static final String TAG_MUSEUM_ITEM_ARTIST = "museum_item_artist"; private static final String TAG_MUSEUM_ITEM_HISTORICAL_PERIOD = "museum_item_historic_period"; private static final String TAG_MUSEUM_ITEM_LOCATION = "museum_item_location"; private static final String TAG_MUSEUM_ITEM_IMAGE = "museum_list_image"; // products JSONArray JSONArray museumItems = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_search_resaults); // Hashmap for ListView museumItemsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); // Loading products in Background Thread new LoadAllProducts().execute(); // Get listview ListView lv = getListView(); } /** * Background Async Task to Load all product by making HTTP Request */ class LoadAllProducts extends AsyncTask&lt;String, String, String&gt; { /** * Before starting background thread Show Progress Dialog */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(DisplaySearchResultsActivity.this); pDialog.setMessage("Loading Museum Items. Please wait..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); } /** * getting All products from url */ protected String doInBackground(String... args) { // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); // getting JSON string from URL JSONObject json = jParser.makeHttpRequest(url_search_results, "GET", params); // Check your log cat for JSON reponse Log.d("All Museum Items: ", json.toString()); try { // Checking for SUCCESS TAG int success = json.getInt(TAG_SUCCESS); if (success == 1) { // products found // Getting Array of Products museumItems = json.getJSONArray(TAG_MUSEUM_ITEMS); // looping through All Products for (int i = 0; i &lt; museumItems.length(); i++) { JSONObject c = museumItems.getJSONObject(i); // Storing each json item in variable String item_id = c.getString(TAG_MUSEUM_ITEM_ID); String item_name = c.getString(TAG_MUSEUM_ITEM_NAME); String item_artist = c.getString(TAG_MUSEUM_ITEM_ARTIST); String item_historic_period = c.getString(TAG_MUSEUM_ITEM_HISTORICAL_PERIOD); String item_location = c.getString(TAG_MUSEUM_ITEM_LOCATION); String list_image = c.getString(TAG_MUSEUM_ITEM_IMAGE); // creating new HashMap HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); // adding each child node to HashMap key =&gt; value map.put(TAG_MUSEUM_ITEM_ID, item_id); map.put(TAG_MUSEUM_ITEM_NAME, item_name); map.put(TAG_MUSEUM_ITEM_ARTIST, item_artist); map.put(TAG_MUSEUM_ITEM_HISTORICAL_PERIOD, item_historic_period); map.put(TAG_MUSEUM_ITEM_LOCATION, item_location); map.put(TAG_MUSEUM_ITEM_IMAGE, list_image); // adding HashList to ArrayList museumItemsList.add(map); } } } catch (JSONException e) { e.printStackTrace(); } return null; } /** * After completing background task Dismiss the progress dialog * * */ protected void onPostExecute(String file_url) { // dismiss the dialog after getting all products pDialog.dismiss(); // updating UI from Background Thread runOnUiThread(new Runnable() { public void run() { /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( DisplaySearchResultsActivity.this, museumItemsList, R.layout.list_item, new String[]{TAG_MUSEUM_ITEM_ID, TAG_MUSEUM_ITEM_NAME, TAG_MUSEUM_ITEM_ARTIST, TAG_MUSEUM_ITEM_HISTORICAL_PERIOD, TAG_MUSEUM_ITEM_LOCATION, TAG_MUSEUM_ITEM_IMAGE}, new int[]{R.id.museum_item_id, R.id.museum_item_name, R.id.museum_item_artist, R.id.museum_item_historic_period, R.id.museum_item_location, R.id.museum_list_image}); // updating listview setListAdapter(adapter); } }); } } } </code></pre> <p>JSONParser.java</p> <pre><code>package com.cloudlionheart.museumsearchapplication; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import org.apache.http.NameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.ListActivity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.SimpleAdapter; import android.widget.TextView; public class DisplaySearchResultsActivity extends ListActivity { // Progress Dialog private ProgressDialog pDialog; // Creating JSON Parser object JSONParser jParser = new JSONParser(); ArrayList&lt;HashMap&lt;String, String&gt;&gt; museumItemsList; // url to get all products list private static String url_search_results = "http://192.168.56.1/android_connect/get_all_products.php"; // JSON Node names private static final String TAG_SUCCESS = "success"; private static final String TAG_MUSEUM_ITEMS = "museum_items"; private static final String TAG_MUSEUM_ITEM_ID = "museum_item_id"; private static final String TAG_MUSEUM_ITEM_NAME = "museum_item_name"; private static final String TAG_MUSEUM_ITEM_ARTIST = "museum_item_artist"; private static final String TAG_MUSEUM_ITEM_HISTORICAL_PERIOD = "museum_item_historic_period"; private static final String TAG_MUSEUM_ITEM_LOCATION = "museum_item_location"; private static final String TAG_MUSEUM_ITEM_IMAGE = "museum_list_image"; // products JSONArray JSONArray museumItems = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_search_resaults); // Hashmap for ListView museumItemsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); // Loading products in Background Thread new LoadAllProducts().execute(); // Get listview ListView lv = getListView(); } /** * Background Async Task to Load all product by making HTTP Request */ class LoadAllProducts extends AsyncTask&lt;String, String, String&gt; { /** * Before starting background thread Show Progress Dialog */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(DisplaySearchResultsActivity.this); pDialog.setMessage("Loading Museum Items. Please wait..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); } /** * getting All products from url */ protected String doInBackground(String... args) { // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); // getting JSON string from URL JSONObject json = jParser.makeHttpRequest(url_search_results, "GET", params); // Check your log cat for JSON reponse Log.d("All Museum Items: ", json.toString()); try { // Checking for SUCCESS TAG int success = json.getInt(TAG_SUCCESS); if (success == 1) { // products found // Getting Array of Products museumItems = json.getJSONArray(TAG_MUSEUM_ITEMS); // looping through All Products for (int i = 0; i &lt; museumItems.length(); i++) { JSONObject c = museumItems.getJSONObject(i); // Storing each json item in variable String item_id = c.getString(TAG_MUSEUM_ITEM_ID); String item_name = c.getString(TAG_MUSEUM_ITEM_NAME); String item_artist = c.getString(TAG_MUSEUM_ITEM_ARTIST); String item_historic_period = c.getString(TAG_MUSEUM_ITEM_HISTORICAL_PERIOD); String item_location = c.getString(TAG_MUSEUM_ITEM_LOCATION); String list_image = c.getString(TAG_MUSEUM_ITEM_IMAGE); // creating new HashMap HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); // adding each child node to HashMap key =&gt; value map.put(TAG_MUSEUM_ITEM_ID, item_id); map.put(TAG_MUSEUM_ITEM_NAME, item_name); map.put(TAG_MUSEUM_ITEM_ARTIST, item_artist); map.put(TAG_MUSEUM_ITEM_HISTORICAL_PERIOD, item_historic_period); map.put(TAG_MUSEUM_ITEM_LOCATION, item_location); map.put(TAG_MUSEUM_ITEM_IMAGE, list_image); // adding HashList to ArrayList museumItemsList.add(map); } } } catch (JSONException e) { e.printStackTrace(); } return null; } /** * After completing background task Dismiss the progress dialog * * */ protected void onPostExecute(String file_url) { // dismiss the dialog after getting all products pDialog.dismiss(); // updating UI from Background Thread runOnUiThread(new Runnable() { public void run() { /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( DisplaySearchResultsActivity.this, museumItemsList, R.layout.list_item, new String[]{TAG_MUSEUM_ITEM_ID, TAG_MUSEUM_ITEM_NAME, TAG_MUSEUM_ITEM_ARTIST, TAG_MUSEUM_ITEM_HISTORICAL_PERIOD, TAG_MUSEUM_ITEM_LOCATION, TAG_MUSEUM_ITEM_IMAGE}, new int[]{R.id.museum_item_id, R.id.museum_item_name, R.id.museum_item_artist, R.id.museum_item_historic_period, R.id.museum_item_location, R.id.museum_list_image}); // updating listview setListAdapter(adapter); } }); } } } </code></pre> <p>and i get the following errors.</p> <pre><code>05-07 10:27:07.177 1942-1962/com.cloudlionheart.museumsearchapplication E/Buffer Error﹕ Error converting result java.lang.NullPointerException: lock == null 05-07 10:27:07.177 1942-1962/com.cloudlionheart.museumsearchapplication E/JSON Parser﹕ Error parsing data org.json.JSONException: End of input at character 0 of 05-07 10:27:07.181 1942-1962/com.cloudlionheart.museumsearchapplication E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #2 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:299) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352) at java.util.concurrent.FutureTask.setException(FutureTask.java:219) at java.util.concurrent.FutureTask.run(FutureTask.java:239) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856) Caused by: java.lang.NullPointerException at com.cloudlionheart.museumsearchapplication.DisplaySearchResultsActivity$LoadAllProducts.doInBackground(DisplaySearchResultsActivity.java:94) at com.cloudlionheart.museumsearchapplication.DisplaySearchResultsActivity$LoadAllProducts.doInBackground(DisplaySearchResultsActivity.java:69) at android.os.AsyncTask$2.call(AsyncTask.java:287) at java.util.concurrent.FutureTask.run(FutureTask.java:234)             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)             at java.lang.Thread.run(Thread.java:856) </code></pre> <p>After hours of search and tries i still can't find the way to make it work</p> </div>

JSON解析器错误java.lang.String无法转换为JSONObject] Array

<div class="post-text" itemprop="text"> <p>Hi guys so my problem is ive developed an app for android that uses json parser to get data from my php webservice and display it into a listview, but when i run the app it shows this:</p> <p>LogCat:</p> <pre><code>E/JSON Parser(1999): Error parsing data [Value Array of type java.lang.String cannot be converted to JSONObject] Array 04-02 13:46:46.982: E/JSON Parser(1079): ( 04-02 13:46:46.982: E/JSON Parser(1079): [id] =&gt; 1 04-02 13:46:46.982: E/JSON Parser(1079): [dt_ini_camp] =&gt; 2012-12-22 04-02 13:46:46.982: E/JSON Parser(1079): [dt_fim_camp] =&gt; 2012-12-24 04-02 13:46:46.982: E/JSON Parser(1079): [descricao] =&gt; Apoios comunit?rios 04-02 13:46:46.982: E/JSON Parser(1079): [qtd] =&gt; 4762.000 04-02 13:46:46.982: E/JSON Parser(1079): ) 04-02 13:46:46.982: E/JSON Parser(1079): Array 04-02 13:46:46.982: E/JSON Parser(1079): ( 04-02 13:46:46.982: E/JSON Parser(1079): [id] =&gt; 2 04-02 13:46:46.982: E/JSON Parser(1079): [dt_ini_camp] =&gt; 2012-10-08 04-02 13:46:46.982: E/JSON Parser(1079): [dt_fim_camp] =&gt; 2012-10-10 04-02 13:46:46.982: E/JSON Parser(1079): [descricao] =&gt; Outras Campanhas 04-02 13:46:46.982: E/JSON Parser(1079): [qtd] =&gt; 3560.000 04-02 13:46:46.982: E/JSON Parser(1079): ) </code></pre> <p>My code:</p> <p>Activity with list view and invokes json parser:</p> <pre><code>public class AllProductsActivity extends ListActivity { // Progress Dialog private ProgressDialog pDialog; // Creating JSON Parser object JSONParser jParser = new JSONParser(); ArrayList&lt;HashMap&lt;String, String&gt;&gt; productsList; // url to get all products list private static String url_all_products = "http://10.0.2.2/webprojecto4/index_pesagem.php"; // JSON Node names private static final String TAG_SUCCESS = "success"; private static final String TAG_PRODUCTS = "cab_doc"; private static final String TAG_ID = "id"; private static final String TAG_NAME = "descricao"; private static final String TAG_DATA = "dt_ini_camp"; private static final String TAG_DATA2 = "dt_fim_camp"; private static final String TAG_QTD = "qtd"; // products JSONArray JSONArray products = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.all_products); // Hashmap for ListView productsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); // Loading products in Background Thread new LoadAllProducts().execute(); // Get listview ListView lv = getListView(); // on seleting single product // launching Edit Product Screen // on seleting single product // launching Edit Product Screen lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { // getting values from selected ListItem String id2 = ((TextView) view.findViewById(R.id.id)).getText() .toString(); // Starting new intent Intent in = new Intent(getApplicationContext(), EditProductActivity.class); // sending pid to next activity in.putExtra(TAG_ID, id); // starting new activity and expecting some response back startActivityForResult(in, 100); } }); } // Response from Edit Product Activity @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // if result code 100 if (resultCode == 100) { // if result code 100 is received // means user edited/deleted product // reload this screen again Intent intent = getIntent(); finish(); startActivity(intent); } } /** * Background Async Task to Load all product by making HTTP Request * */ class LoadAllProducts extends AsyncTask&lt;String, String, String&gt; { /** * Before starting background thread Show Progress Dialog * */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(AllProductsActivity.this); pDialog.setMessage("Loading products. Please wait..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); } /** * getting All products from url * */ protected String doInBackground(String... args) { // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); // getting JSON string from URL JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params); // Check your log cat for JSON reponse Log.d("All Products: ", json.toString()); try { // Checking for SUCCESS TAG int success = json.getInt(TAG_SUCCESS); if (success == 1) { // products found // Getting Array of Products products = json.getJSONArray(TAG_PRODUCTS); // looping through All Products for (int i = 0; i &lt; products.length(); i++) { JSONObject c = products.getJSONObject(i); // Storing each json item in variable String id = c.getString(TAG_ID); String name = c.getString(TAG_NAME); String data = c.getString(TAG_DATA); String data2 = c.getString(TAG_DATA2); String qtd = c.getString(TAG_QTD); // creating new HashMap HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); // adding each child node to HashMap key =&gt; value map.put(TAG_ID, id); map.put(TAG_NAME, name); map.put(TAG_DATA, data); map.put(TAG_DATA2, data2); map.put(TAG_QTD, qtd); // adding HashList to ArrayList productsList.add(map); } } else { // no products found // Launch Add New product Activity Intent i = new Intent(getApplicationContext(), NewProductActivity.class); // Closing all previous activities i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); } } catch (JSONException e) { e.printStackTrace(); } return null; } /** * After completing background task Dismiss the progress dialog * **/ protected void onPostExecute(String file_url) { // dismiss the dialog after getting all products pDialog.dismiss(); // updating UI from Background Thread runOnUiThread(new Runnable() { public void run() { /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( AllProductsActivity.this, productsList, R.layout.list_item, new String[] { TAG_ID, TAG_NAME, TAG_DATA, TAG_DATA2, TAG_QTD}, new int[] { R.id.id, R.id.descricao, R.id.data, R.id.data2, R.id.qtd }); // updating listview setListAdapter(adapter); } }); } } } </code></pre> <p>Json Parser in this i only changed this line BufferedReader reader = new BufferedReader(new InputStreamReader(is, "utf-8"), 8); instead of utf-8 it was iso-8859-1 ive searched for this error and based on answers i found it said it would be better utf-8 but it didnt fixed the problem</p> <pre><code>public class JSONParser { static InputStream is = null; static JSONObject jObj = null; static String json = ""; // constructor public JSONParser() { } // function get json from url // by making HTTP POST or GET mehtod public JSONObject makeHttpRequest(String url, String method, List&lt;NameValuePair&gt; params) { // Making HTTP request try { // check for request method if(method == "POST"){ // request method is POST // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); }else if(method == "GET"){ // request method is GET DefaultHttpClient httpClient = new DefaultHttpClient(); String paramString = URLEncodedUtils.format(params, "utf-8"); url += "?" + paramString; HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader( is, "utf-8"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + " "); } is.close(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } // try parse the string to a JSON object try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data [" + e.getMessage()+"] "+json); } // return JSON String return jObj; } } </code></pre> <p>And my php service:</p> <pre><code>&lt;?php /* * Following code will list all the products */ // array for JSON response $response = array(); // include db connect class require_once __DIR__ . '/conectaDB.php'; // connecting to db $db = new DB_CONNECT(); // get all products from products table $result = mysql_query("select cd.id, cd.dt_ini_camp, cd.dt_fim_camp, cd.descricao, + (select sum(quantidade) from lin_doc where id_cab_doc = cd.id) as qtd from cab_doc cd where cd.id_tipo_doc = 1") or die(mysql_error()); // check for empty result if (mysql_num_rows($result) &gt; 0) { // looping through all results // products node $response["cab_doc"] = array(); while ($row = mysql_fetch_array($result)) { // temp user array $product = array(); $product["id"] = $row["id"]; $product["dt_ini_camp"] = $row["dt_ini_camp"]; $product["dt_fim_camp"] = $row["dt_fim_camp"]; $product["descricao"] = $row["descricao"]; $product["qtd"] = $row["qtd"]; // push single product into final response array array_push($response["cab_doc"], $product); print_r($product); } // success $response["success"] = 1; // echoing JSON response echo json_encode($response); } else { // no products found $response["success"] = 0; $response["message"] = "No products found"; // echo no users JSON echo json_encode($response); } ?&gt; </code></pre> <p>Please guys i really need help i dont find the problem, the problem i find lol i dont find the answer to my problem xD</p> </div>

线程一直处于RUNNABLE,也没有发现阻塞或是死锁的情况?

我写的是一个频繁访问网络的爬虫,启了20个线程; 但是老实跑了一段时间,线程全部处于RUNNABLE状态了; 网络使用的是httpclient3.1; 我把threaddump给放到下面: ``` "Thread-19" #30 prio=5 os_prio=0 tid=0x0000000059b3d000 nid=0xcb4 runnable [0x000000005ba1e000] java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:150) at java.net.SocketInputStream.read(SocketInputStream.java:121) at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) at java.io.BufferedInputStream.read(BufferedInputStream.java:265) - locked <0x0000000086f05c90> (a java.io.BufferedInputStream) at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78) at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106) at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116) at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973) at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) at com.uzons.domain.search.v2.searcher.EBChecker.validate(EBChecker.java:34) at com.uzons.domain.search.v2.taskscheduler.DomainJob.exec(DomainJob.java:28) at com.uzons.domain.search.v2.taskscheduler.DomainScheduler.execute(DomainScheduler.java:110) at com.uzons.domain.search.v2.taskscheduler.DomainScheduler.run(DomainScheduler.java:92) Locked ownable synchronizers: - None ```

错误:org.json.JSONException:java.lang.String类型的值<br无法转换为JSONObject

<div class="post-text" itemprop="text"> <p>I know I have seen all similar questions on SO. I tried to solve this error but I failed. I tried almost everything but does not get solution.</p> <p>My code is as follows:-</p> <pre><code>public class Tab2 extends Fragment { private static String TAG = Tab2.class.getSimpleName(); private EditText editText1,editText2,editText3; private Button button; private String name,email,password; private TextInputLayout inputLayoutName, inputLayoutEmail, inputLayoutPassword; private ProgressDialog pDialog; private SessionManager session; private database db; static InputStream is = null; static JSONObject jObj = null; static String json = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tab2,container,false); pDialog = new ProgressDialog(getActivity()); pDialog.setCancelable(false); // Session manager session = new SessionManager(getActivity()); // SQLite database handler db = new database(getActivity()); // Check if user is already logged in or not if (session.isLoggedIn()) { // User is already logged in. Take him to main activity Intent intent = new Intent(getActivity(),MainActivity.class); startActivity(intent); } editText1 = (EditText)view.findViewById(R.id.name); editText2 = (EditText)view.findViewById(R.id.email); editText3 = (EditText)view.findViewById(R.id.password); inputLayoutEmail = (TextInputLayout)view. findViewById(R.id.view1); inputLayoutPassword = (TextInputLayout)view. findViewById(R.id.view2); inputLayoutName = (TextInputLayout)view. findViewById(R.id.view3); button = (Button)view.findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view1) { name = editText1.getText().toString().trim(); email = editText2.getText().toString().trim(); password = editText3.getText().toString().trim(); if (!validateName() || !validateEmail() || !validatePassword() ) { Log.d(TAG, "Successfull"); return; } try { new Thread(new Runnable() { @Override public void run() { registerUser(name, email, password); } }).start(); }catch (NullPointerException e){ e.printStackTrace(); } Toast.makeText(getActivity(), "Account Created Successfully!", Toast.LENGTH_SHORT).show(); Intent i = new Intent(getActivity(), MainActivity.class); startActivity(i); } }); return view; } public boolean validateName(){ if(name.isEmpty() ) { inputLayoutName.setError(getString(R.string.error_name1)); return false; } else if(name.length()&lt;3){ inputLayoutName.setError(getString(R.string.error_name2)); return false; } else inputLayoutName.setErrorEnabled(false); return true; } public boolean validateEmail(){ if(email.isEmpty() || !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()){ inputLayoutEmail.setError(getString(R.string.error_email)); return false; } else inputLayoutEmail.setErrorEnabled(false); return true; } public boolean validatePassword(){ if(password.isEmpty() ){ inputLayoutPassword.setError(getString(R.string.error_password1)); return false; } else if(password.length()&lt;4){ inputLayoutPassword.setError(getString(R.string.error_password2)); return false; } else inputLayoutPassword.setErrorEnabled(false); return true; } public void registerUser(final String name, final String email, final String password){ String req = "req_request"; pDialog.setMessage("Registering ..."); showDialog(); RequestQueue requestQueue = Volley.newRequestQueue(getActivity()); StringRequest strReq = new StringRequest(Request.Method.POST, appConfig.url_sign, new Response.Listener&lt;String&gt;(){ @Override public void onResponse(String response) { try { JSONObject jObj = new JSONObject(response); boolean error = jObj.getBoolean("error"); Log.d(TAG,name + " " + email + " " + password ); if (!error) { String uid = jObj.getString("uid"); JSONObject user = jObj.getJSONObject("user"); String name = user.getString("name"); String email= user.getString("email"); String created_at = user.getString("created_at"); db.addUser(name, email, uid, created_at); Toast.makeText(getActivity(), "User successfully registered. Try login now!", Toast.LENGTH_LONG).show(); // Launch login activity Intent i = new Intent( getActivity(), Login.class); startActivity(i); } else { String errorMsg = jObj.getString("error_msg"); Toast.makeText(getActivity(), errorMsg, Toast.LENGTH_LONG).show(); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { NetworkResponse networkResponse = error.networkResponse; if (networkResponse != null) { Log.e("Volley", "Error. HTTP Status Code:"+networkResponse.statusCode); } if (error instanceof TimeoutError) { Log.e("Volley", "TimeoutError"); }else if(error instanceof NoConnectionError){ Log.e("Volley", "NoConnectionError"); } else if (error instanceof AuthFailureError) { Log.e("Volley", "AuthFailureError"); } else if (error instanceof ServerError) { Log.e("Volley", "ServerError"); } else if (error instanceof NetworkError) { Log.e("Volley", "NetworkError"); } else if (error instanceof ParseError) { Log.e("Volley", "ParseError"); } //Log.e(TAG, "Registration Error: " + error.getMessage()); // Toast.makeText(getActivity(), // error.getMessage(), Toast.LENGTH_LONG).show(); // hideDialog(); } }) { @Override protected Map&lt;String, String&gt; getParams() { // Posting params to register url Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;(); params.put("name", name); params.put("email", email); params.put("password", password); return params; } }; int socketTimeout = 10000;//30 seconds - change to what you want RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); strReq.setRetryPolicy(policy); requestQueue.add(strReq); } private void showDialog() { if (!pDialog.isShowing()) pDialog.show(); } private void hideDialog() { if (pDialog.isShowing()) pDialog.dismiss(); } } </code></pre> <p>This is my php file</p> <pre><code>&lt;?php $response = array(); if (isset($_POST['name']) &amp;&amp; isset($_POST['email']) &amp;&amp; isset ($_POST['password'] )) { $name = $_POST['name']; $email = $_POST['email']; $password = $_POST['password']; require_once __DIR__ . '/db_connection.php'; $db = new DB_CONNECT(); $result = mysql_query("Insert into words(name,email,password) values('$name','$email','$password')"); if ($result) { $response["success"] = 1; $response["message"] = "Registration successfully."; echo json_encode($response); } else { $response["success"] = 0; $response["message"] = "Oops! An error occurred."; echo json_encode($response); } } else { $response["success"] = 0; $response["message"] = "Required field(s) is missing"; echo json_encode($response); } ?&gt; </code></pre> <p>My JSON response is:-</p> <pre><code>{"success":0,"message":"Required field(s) is missing"} </code></pre> <p>Can you identify the error please tell me.</p> </div>

急求。。。。。看下java的dump文件,会这样

2015-03-18 22:38:54 Full thread dump Java HotSpot(TM) Client VM (20.1-b02 mixed mode, sharing): "Attach Listener" daemon prio=10 tid=0x089f1c00 nid=0x1df1 waiting on condition [0x00000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "DestroyJavaVM" prio=10 tid=0x0806f400 nid=0x1297 waiting on condition [0x00000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "pool-1-thread-1" prio=10 tid=0x08a70c00 nid=0x1341 waiting on condition [0xb4806000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x7a13b978> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:399) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:662) Locked ownable synchronizers: - None "Low Memory Detector" daemon prio=10 tid=0x080b3800 nid=0x129d runnable [0x00000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C1 CompilerThread0" daemon prio=10 tid=0x080a8000 nid=0x129c waiting on condition [0x00000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "Signal Dispatcher" daemon prio=10 tid=0x080a6800 nid=0x129b runnable [0x00000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "Finalizer" daemon prio=10 tid=0x0809e800 nid=0x129a in Object.wait() [0xb4ed9000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x7a040258> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118) - locked <0x7a040258> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159) Locked ownable synchronizers: - None "Reference Handler" daemon prio=10 tid=0x0809d400 nid=0x1299 in Object.wait() [0xb4f2b000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x7a0402e8> (a java.lang.ref.Reference$Lock) at java.lang.Object.wait(Object.java:485) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116) - locked <0x7a0402e8> (a java.lang.ref.Reference$Lock) Locked ownable synchronizers: - None "VM Thread" prio=10 tid=0x08092c00 nid=0x1298 runnable "VM Periodic Task Thread" prio=10 tid=0x080b5800 nid=0x129e waiting on condition JNI global references: 1109 我使用了Executors.newFixedThreadPool线程池来执行任务,,,主进程退出不了。 为什么啊???

Springboot刚启动就报内存溢出?

1.问题描述: 本地系统是Ubuntu,jdk1.8,工具是eclipse,新创建的最简单的springboot项目,其中只导入了web、config的包。 只写了一个controller,启动就会报错。 Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.201-b09 mixed mode): "DestroyJavaVM" #39 prio=5 os_prio=0 tid=0x00007f0ae800f000 nid=0x697c waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "http-nio-8080-Acceptor-0" #37 daemon prio=5 os_prio=0 tid=0x00007f0ae8224800 nid=0x69ae runnable [0x00007f0ac26ed000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method) at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:422) at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:250) - locked <0x000000076f448c40> (a java.lang.Object) at org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept(NioEndpoint.java:448) at org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept(NioEndpoint.java:70) at org.apache.tomcat.util.net.Acceptor.run(Acceptor.java:95) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-ClientPoller-1" #36 daemon prio=5 os_prio=0 tid=0x00007f0ae821f000 nid=0x69ad runnable [0x00007f0ac27ee000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method) at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269) at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:93) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) - locked <0x000000076f5c05c0> (a sun.nio.ch.Util$3) - locked <0x000000076f5c05b0> (a java.util.Collections$UnmodifiableSet) - locked <0x000000076f5c0498> (a sun.nio.ch.EPollSelectorImpl) at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97) at org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:743) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-ClientPoller-0" #35 daemon prio=5 os_prio=0 tid=0x00007f0ae821d000 nid=0x69ac runnable [0x00007f0ac28ef000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method) at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269) at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:93) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) - locked <0x000000076f5afb78> (a sun.nio.ch.Util$3) - locked <0x000000076f5afb68> (a java.util.Collections$UnmodifiableSet) - locked <0x000000076f5afa50> (a sun.nio.ch.EPollSelectorImpl) at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97) at org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:743) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-exec-10" #34 daemon prio=5 os_prio=0 tid=0x00007f0ae82b5800 nid=0x69ab waiting on condition [0x00007f0ac29f0000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076f59e010> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:107) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-exec-9" #33 daemon prio=5 os_prio=0 tid=0x00007f0ae82b4000 nid=0x69aa waiting on condition [0x00007f0ac2af1000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076f59e010> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:107) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-exec-8" #32 daemon prio=5 os_prio=0 tid=0x00007f0ae82b2000 nid=0x69a9 waiting on condition [0x00007f0ac2bf2000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076f59e010> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:107) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-exec-7" #31 daemon prio=5 os_prio=0 tid=0x00007f0ae82b0000 nid=0x69a8 waiting on condition [0x00007f0ac2cf3000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076f59e010> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:107) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-exec-6" #30 daemon prio=5 os_prio=0 tid=0x00007f0ae82ae000 nid=0x69a7 waiting on condition [0x00007f0ac2df4000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076f59e010> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:107) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-exec-5" #29 daemon prio=5 os_prio=0 tid=0x00007f0ae8256800 nid=0x69a6 waiting on condition [0x00007f0ac2ef5000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076f59e010> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:107) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-exec-4" #28 daemon prio=5 os_prio=0 tid=0x00007f0ae8254800 nid=0x69a5 waiting on condition [0x00007f0ac2ff6000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076f59e010> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:107) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-exec-3" #27 daemon prio=5 os_prio=0 tid=0x00007f0ae8252800 nid=0x69a4 waiting on condition [0x00007f0ac30f7000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076f59e010> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:107) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-exec-2" #26 daemon prio=5 os_prio=0 tid=0x00007f0ae8251000 nid=0x69a3 waiting on condition [0x00007f0ac31f8000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076f59e010> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:107) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "http-nio-8080-exec-1" #25 daemon prio=5 os_prio=0 tid=0x00007f0ae824f800 nid=0x69a2 waiting on condition [0x00007f0ac32f9000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076f59e010> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:107) at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "NioBlockingSelector.BlockPoller-1" #24 daemon prio=5 os_prio=0 tid=0x00007f0ae82e3800 nid=0x69a1 runnable [0x00007f0ac33fa000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method) at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269) at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:93) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) - locked <0x000000076f44a298> (a sun.nio.ch.Util$3) - locked <0x000000076f44a210> (a java.util.Collections$UnmodifiableSet) - locked <0x000000076f44a090> (a sun.nio.ch.EPollSelectorImpl) at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97) at org.apache.tomcat.util.net.NioBlockingSelector$BlockPoller.run(NioBlockingSelector.java:304) "spring.cloud.inetutils" #23 daemon prio=5 os_prio=0 tid=0x00007f0ae82fb800 nid=0x69a0 waiting on condition [0x00007f0ac34fb000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076e593b10> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) "SimplePauseDetectorThread_0" #22 daemon prio=9 os_prio=0 tid=0x00007f0a84015000 nid=0x699f waiting on condition [0x00007f0ac37fc000] java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) at java.lang.Thread.sleep(Thread.java:340) at java.util.concurrent.TimeUnit.sleep(TimeUnit.java:386) at org.LatencyUtils.TimeServices.sleepNanos(TimeServices.java:62) at org.LatencyUtils.SimplePauseDetector$SimplePauseDetectorThread.run(SimplePauseDetector.java:116) "Thread-4" #21 daemon prio=9 os_prio=0 tid=0x00007f0a84011800 nid=0x699e waiting on condition [0x00007f0ac38fd000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000006c7b7a928> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at org.LatencyUtils.PauseDetector$PauseDetectorThread.run(PauseDetector.java:85) "container-0" #20 prio=5 os_prio=0 tid=0x00007f0ae8c72800 nid=0x699d waiting on condition [0x00007f0ac39fe000] java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) at org.apache.catalina.core.StandardServer.await(StandardServer.java:568) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer$1.run(TomcatWebServer.java:181) "Catalina-utility-2" #19 prio=1 os_prio=0 tid=0x00007f0a68314800 nid=0x699c waiting on condition [0x00007f0ac8dfd000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000006c7ab4300> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1088) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "Catalina-utility-1" #18 prio=1 os_prio=0 tid=0x00007f0ae8c6a800 nid=0x699b waiting on condition [0x00007f0ad0143000] java.lang.Thread.State: TIMED_WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000006c7ab4300> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "RMI TCP Accept-0" #13 daemon prio=5 os_prio=0 tid=0x00007f0ae850a000 nid=0x6995 runnable [0x00007f0ad056d000] java.lang.Thread.State: RUNNABLE at java.net.PlainSocketImpl.socketAccept(Native Method) at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409) at java.net.ServerSocket.implAccept(ServerSocket.java:545) at java.net.ServerSocket.accept(ServerSocket.java:513) at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(LocalRMIServerSocketFactory.java:52) at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:405) at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:377) at java.lang.Thread.run(Thread.java:748) "RMI TCP Accept-43459" #12 daemon prio=5 os_prio=0 tid=0x00007f0ae84ca000 nid=0x6994 runnable [0x00007f0ad0694000] java.lang.Thread.State: RUNNABLE at java.net.PlainSocketImpl.socketAccept(Native Method) at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409) at java.net.ServerSocket.implAccept(ServerSocket.java:545) at java.net.ServerSocket.accept(ServerSocket.java:513) at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:405) at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:377) at java.lang.Thread.run(Thread.java:748) "RMI TCP Accept-0" #11 daemon prio=5 os_prio=0 tid=0x00007f0ae84b5000 nid=0x6993 runnable [0x00007f0ad0795000] java.lang.Thread.State: RUNNABLE at java.net.PlainSocketImpl.socketAccept(Native Method) at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409) at java.net.ServerSocket.implAccept(ServerSocket.java:545) at java.net.ServerSocket.accept(ServerSocket.java:513) at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:405) at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:377) at java.lang.Thread.run(Thread.java:748) "Service Thread" #9 daemon prio=9 os_prio=0 tid=0x00007f0ae80d8000 nid=0x6992 runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE "C1 CompilerThread3" #8 daemon prio=9 os_prio=0 tid=0x00007f0ae80cc800 nid=0x6991 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "C2 CompilerThread2" #7 daemon prio=9 os_prio=0 tid=0x00007f0ae80ca800 nid=0x6990 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "C2 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007f0ae80c9000 nid=0x698f waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007f0ae80c6000 nid=0x698e waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007f0ae80c4800 nid=0x698d waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007f0ae8091800 nid=0x698c in Object.wait() [0x00007f0ad26de000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000006c701d718> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144) - locked <0x00000006c701d718> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:165) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:216) "Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007f0ae808f000 nid=0x698b in Object.wait() [0x00007f0ad27df000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000006c7034928> (a java.lang.ref.Reference$Lock) at java.lang.Object.wait(Object.java:502) at java.lang.ref.Reference.tryHandlePending(Reference.java:191) - locked <0x00000006c7034928> (a java.lang.ref.Reference$Lock) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153) "VM Thread" os_prio=0 tid=0x00007f0ae8085800 nid=0x698a runnable "GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007f0ae8025000 nid=0x6980 runnable "GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007f0ae8026800 nid=0x6981 runnable "GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00007f0ae8028800 nid=0x6982 runnable "GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00007f0ae802a000 nid=0x6983 runnable "GC task thread#4 (ParallelGC)" os_prio=0 tid=0x00007f0ae802c000 nid=0x6984 runnable "GC task thread#5 (ParallelGC)" os_prio=0 tid=0x00007f0ae802d800 nid=0x6987 runnable "GC task thread#6 (ParallelGC)" os_prio=0 tid=0x00007f0ae802f800 nid=0x6988 runnable "GC task thread#7 (ParallelGC)" os_prio=0 tid=0x00007f0ae8031000 nid=0x6989 runnable "VM Periodic Task Thread" os_prio=0 tid=0x00007f0ae850c000 nid=0x6996 waiting on condition JNI global references: 1235 Heap PSYoungGen total 144384K, used 45005K [0x000000076d000000, 0x0000000777b00000, 0x00000007c0000000) eden space 126976K, 35% used [0x000000076d000000,0x000000076fbf3608,0x0000000774c00000) from space 17408K, 0% used [0x0000000775d00000,0x0000000775d00000,0x0000000776e00000) to space 17408K, 0% used [0x0000000774c00000,0x0000000774c00000,0x0000000775d00000) ParOldGen total 175616K, used 22110K [0x00000006c7000000, 0x00000006d1b80000, 0x000000076d000000) object space 175616K, 12% used [0x00000006c7000000,0x00000006c85978a8,0x00000006d1b80000) Metaspace used 35192K, capacity 37248K, committed 37504K, reserved 1081344K class space used 4819K, capacity 5214K, committed 5248K, reserved 1048576K 2019-04-01 14:22:57.992 INFO 27001 --- [on(2)-127.0.0.1] inMXBeanRegistrar$SpringApplicationAdmin : Application shutdown requested. 2019-04-01 14:22:57.994 INFO 27001 --- [on(2)-127.0.0.1] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' 2019-04-01 14:22:58.004 INFO 27001 --- [on(2)-127.0.0.1] o.apache.catalina.core.StandardService : Stopping service [Tomcat] ``` ```

关于Java多线程的问题,求大神解决

一个简单的例子,一个线程类代表客户,一个线程类代表厨师, 厨师每做好5个包子两个客户就吃,吃完再做。 运行时出现 java.lang.IllegalMonitorStateException错误,而且每次都只是一个人在吃。 实在是弄不明白了。。。 代码如下: public class Resource { //锁对象,静态资源,可以被公开访问 static Object lock = new Object(); //包子容器,静态资源,可以被公开访问 static List<String> container = new ArrayList<String>(); } public class Producer implements Runnable { @Override public void run() { // TODO Auto-generated method stub while (true) { synchronized ("") { if (Resource.container.size() == 5) { Resource.lock.notifyAll();// 唤醒所有在等待Resource.lock这把锁的线程 } else { System.out.println("开始制作包子"); // 模拟耗时 try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } Resource.container.add("包子"); } } } } } public class Cutstom implements Runnable { @Override public void run() { // TODO Auto-generated method stub while (true) { synchronized ("") { // 容器中没有包子了,吃货们就要等待包子 if (Resource.container.size() == 0) { System.out.println("包子吃光啦,老板上包子"); try { Resource.lock.wait();// 释放自己持有了锁,并开始等待被notify } catch (InterruptedException e) { e.printStackTrace(); } } else { // 模拟耗时 try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } // 移除吃过的包子 System.out.println("吃货:" + Thread.currentThread().getName() + "吃包子"); Resource.container.remove(0); } } } } } public class Test { public static void main(String[] args) { // TODO Auto-generated method stub Cutstom cutstom = new Cutstom() ; new Thread(cutstom,"a").start() ; new Thread(cutstom,"b").start() ; Producer producer = new Producer() ; new Thread(producer,"c").start(); } } console: Exception in thread "a" 包子吃光啦,老板上包子 java.lang.IllegalMonitorStateException at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Unknown Source) at food.Cutstom.run(Cutstom.java:15) at java.lang.Thread.run(Unknown Source) 开始制作包子 开始制作包子 开始制作包子 开始制作包子 开始制作包子 Exception in thread "c" java.lang.IllegalMonitorStateException at java.lang.Object.notifyAll(Native Method) at food.Producer.run(Producer.java:10) at java.lang.Thread.run(Unknown Source) 吃货:b吃包子 吃货:b吃包子 吃货:b吃包子 吃货:b吃包子 吃货:b吃包子 包子吃光啦,老板上包子 Exception in thread "b" java.lang.IllegalMonitorStateException at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Unknown Source) at food.Cutstom.run(Cutstom.java:15) at java.lang.Thread.run(Unknown Source)

JAVA项目运行cup占用率100%,使用explorer工具查询java.exe下的线程占用率过高(如图),谁帮助分析下?

![图片说明](https://img-ask.csdn.net/upload/201906/26/1561532013_676978.jpg) 定位在如下的的日志上,请帮助分析。谢谢! 2019-06-26 14:34:07 "XNIO-1 Accept" #19 daemon prio=5 os_prio=0 tid=0x0000000058231000 nid=0x3ec runnable [0x000000005badf000] java.lang.Thread.State: RUNNABLE at java.lang.Object.notifyAll(Native Method) at sun.nio.ch.WindowsSelectorImpl$StartLock.startThreads(WindowsSelectorImpl.java:189) - locked <0x00000000d3d825c0> (a sun.nio.ch.WindowsSelectorImpl$StartLock) at sun.nio.ch.WindowsSelectorImpl$StartLock.access$300(WindowsSelectorImpl.java:181) at sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:153) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) - locked <0x00000000d3d71eb8> (a sun.nio.ch.Util$2) - locked <0x00000000d3d71ec8> (a java.util.Collections$UnmodifiableSet) - locked <0x00000000d3d71e38> (a sun.nio.ch.WindowsSelectorImpl) at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97) at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:101) at org.xnio.nio.WorkerThread.run(WorkerThread.java:511) Locked ownable synchronizers: - None "XNIO-1 I/O-1" #18 daemon prio=5 os_prio=0 tid=0x0000000054092800 nid=0xf54 runnable [0x000000005b85f000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method) at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296) at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278) at sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86) - locked <0x00000000d3d751e0> (a sun.nio.ch.Util$2) - locked <0x00000000d3d751f0> (a java.util.Collections$UnmodifiableSet) - locked <0x00000000d3d75160> (a sun.nio.ch.WindowsSelectorImpl) at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97) at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:101) at org.xnio.nio.WorkerThread.run(WorkerThread.java:511) Locked ownable synchronizers: - None

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $报错

使用gson出现的问题,logcat显示如下 Process: vip.markxu.instagram1, PID: 12426 ``` com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226) at com.google.gson.Gson.fromJson(Gson.java:927) at com.google.gson.Gson.fromJson(Gson.java:892) at com.google.gson.Gson.fromJson(Gson.java:841) at com.google.gson.Gson.fromJson(Gson.java:813) at vip.markxu.instagram.fuhaoyi.LoginActivity$1$1.run(LoginActivity.java:104) at android.os.Handler.handleCallback(Handler.java:754) ``` 试过网上说的方法,每一个具体例子,大概都是说后台程序返回数据格式不正确,有理但没用。 -———————————————————————————————— 代码段 UserPOJO类 ``` public class UserPOJO { private String userid; private String account; private String password; private String userfavicon; private String username; private int status; public UserPOJO(String userid,String account,String password,String userfavicon,String username,int status){ this.userid=userid; this.account=account; this.password=password; this.userfavicon=userfavicon; this.username=username; this.status=status; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getAccount() { return account; } public void setAccount(String account) { this.account = account; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getUserid() { return userid; } public void setUserid(String userid) { this.userid = userid; } public String getUserfavicon() { return userfavicon; } public void setUserfavicon(String userfavicon) { this.userfavicon = userfavicon; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } } ``` 应用gson代码段 ```java public void registerWithOkHttp(String address,String account,String password){ HttpUtil.registerWithOkHttp(address, account, password, new Callback() { @Override public void onFailure(Call call, IOException e) { //在这里对异常情况进行处理 } @Override public void onResponse(Call call, Response response) throws IOException { final String responseData = response.body().string(); runOnUiThread(new Runnable() { @Override public void run() { Gson gson=new Gson(); //报错地方 user = gson.fromJson(responseData, UserPOJO.class); if(user.getStatus()==1){ SharedPreferences sharedPreferences = getSharedPreferences("user", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("user_id", user.getUserid()); editor.putString("userfavicon",user.getUserfavicon()); editor.apply(); Intent intent = new Intent(LoginActivity.this, MainActivity.class); startActivity(intent); finish(); } else{ Toast.makeText(LoginActivity.this,"注册失败",Toast.LENGTH_SHORT).show(); } } }); } }); } ``` json格式: ``` package vip.markxu.instagram.xiexizhou.Utils; import java.io.Serializable; import java.util.List; public class IndexJson implements Serializable { List<item> data; public List<item> getList() { return data; } @Override public String toString() { return "IndexJson{" + "data=" + data + '}'; } public void setList(List<item> list) { this.data = list; } public static class item implements Serializable{ private Integer comments_numb; private String contents; private String img; private String mime; private String post_id; private String postdate; private String userid; private String userfavicon; private String likes; private String username; private List<Comments> comments; public List<Comments> getComments() { return comments; } public void setComments(List<Comments> comments) { this.comments = comments; } public static class Comments implements Serializable{ private String comment_id; private String comment_time; private String content; private String post_id; private String username; private String user_favicon; public String getUser_favicon() { return user_favicon; } public void setUser_favicon(String user_favicon) { this.user_favicon = user_favicon; } public String getComment_id() { return comment_id; } public void setComment_id(String comment_id) { this.comment_id = comment_id; } public String getComment_time() { return comment_time; } public void setComment_time(String comment_time) { this.comment_time = comment_time; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public String getPost_id() { return post_id; } public void setPost_id(String post_id) { this.post_id = post_id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } } @Override public String toString() { return "item{" + "comments_numb=" + comments_numb + ", contents='" + contents + '\'' + ", img='" + img + '\'' + ", mime='" + mime + '\'' + ", post_id='" + post_id + '\'' + ", postdate='" + postdate + '\'' + ", userid='" + userid + '\'' + ", userfavicon='" + userfavicon + '\'' + ", likes='" + likes + '\'' + ", username='" + username + '\'' + '}'; } public String getUserfavicon() { return userfavicon; } public void setUserfavicon(String userfavicon) { this.userfavicon = userfavicon; } public String getLikes() { return likes; } public void setLikes(String likes) { this.likes = likes; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public Integer getComments_numb() { return comments_numb; } public void setComments_numb(Integer comments_numb) { this.comments_numb = comments_numb; } public String getContents() { return contents; } public void setContents(String contents) { this.contents = contents; } public String getImg() { return img; } public void setImg(String img) { this.img = img; } public String getMime() { return mime; } public void setMime(String mime) { this.mime = mime; } public String getPost_id() { return post_id; } public void setPost_id(String post_id) { this.post_id = post_id; } public String getPostdate() { return postdate; } public void setPostdate(String postdate) { this.postdate = postdate; } public String getUserid() { return userid; } public void setUserid(String userid) { this.userid = userid; } } } ``` 求解决,具体方法

一个SplashActivity出现闪退,使用的Lean Cloud AVUSER 问题:Caused by: java.lang.StringIndexOutOfBoundsException: length=0; index=8

``` public class SplashActivity extends BaseActivity { private static final int DELAY_TIME = 2000; @Override protected int getLayoutResID() { return R.layout.activity_splash; } @Override protected void init() { super.init(); //获取当前用户 User currentUser = AVUser.getCurrentUser(User.class); if (currentUser == null){ navigateToLoginActivity(); } else { navigateToMainActivity(); } } private void navigateToMainActivity() { postDelay(new Runnable() { @Override public void run() { //跳转到登陆界面 navigateTo(MainActivity.class); } }, DELAY_TIME); } private void navigateToLoginActivity() { postDelay(new Runnable() { @Override public void run() { //跳转到登陆界面 navigateTo(LoginActivity.class); } }, DELAY_TIME); } } ``` ``` public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); AVOSCloud.initialize(this, Constant.APP_ID, Constant.APP_KEY,Constant.Server_URL); } ```

运行 sbt 时报错,是什么问题?

-VirtualBox:~/Android/jvm$ sbt [info] Loading project definition from /home/ng/AndroidToolChain/jvm-toxcore-c/project java.lang.NullPointerException at java.base/java.util.regex.Matcher.getTextLength(Matcher.java:1770) at java.base/java.util.regex.Matcher.reset(Matcher.java:416) at java.base/java.util.regex.Matcher.<init>(Matcher.java:253) at java.base/java.util.regex.Pattern.matcher(Pattern.java:1133) at java.base/java.util.regex.Pattern.split(Pattern.java:1261) at java.base/java.util.regex.Pattern.split(Pattern.java:1334) at sbt.IO$.pathSplit(IO.scala:797) at sbt.IO$.parseClasspath(IO.scala:912) at sbt.compiler.CompilerArguments.extClasspath(CompilerArguments.scala:66) at sbt.compiler.MixedAnalyzingCompiler$.withBootclasspath(MixedAnalyzingCompiler.scala:188) at sbt.compiler.MixedAnalyzingCompiler$.searchClasspathAndLookup(MixedAnalyzingCompiler.scala:166) at sbt.compiler.MixedAnalyzingCompiler$.apply(MixedAnalyzingCompiler.scala:176) at sbt.compiler.IC$.incrementalCompile(IncrementalCompiler.scala:138) at sbt.Compiler$.compile(Compiler.scala:152) at sbt.Compiler$.compile(Compiler.scala:138) at sbt.Defaults$.sbt$Defaults$$compileIncrementalTaskImpl(Defaults.scala:860) at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:851) at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:849) at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47) at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40) at sbt.std.Transform$$anon$4.work(System.scala:63) at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228) at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228) at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17) at sbt.Execute.work(Execute.scala:237) at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228) at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228) at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159) at sbt.CompletionService$$anon$2.call(CompletionService.scala:28) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:835) ``` ```

netty启动报错找不到ServerBootstrap.channel

本人在一个tomcat容器的JavaWeb项目中打算用netty与硬件端进行通信,写了一个netty服务如下 ``` public class NettyServer extends HttpServlet{ private static final int port = 12888; // java.lang.NoSuchMethodError: public void bind() throws Exception{ EventLoopGroup bossGroup = new NioEventLoopGroup(); EventLoopGroup workerGroup = new NioEventLoopGroup(); System.out.println("start group handler"); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 100) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel socketChannel) throws Exception { // socketChannel.pipeline().addLast(new MsgDecoder(1024*1024,4,4)); // socketChannel.pipeline().addLast(new MsgDecoder(1024*1024,4,4)); socketChannel.pipeline().addLast("readTimeOutHandler", new ReadTimeoutHandler(50)); socketChannel.pipeline().addLast(new LoginAuthRespHandler()); socketChannel.pipeline().addLast(new HeartBeatRespHandler()); socketChannel.pipeline().addLast(new NettyServerHandler()); } }); System.out.println("start bind"); // b.bind(port).sync(); ChannelFuture f = b.bind(port).sync(); System.out.println("netty Server start listen in port " + port); f.channel().closeFuture().sync(); }finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } } @Override public void init() throws ServletException { try { new NettyServer().bind(); } catch (Exception e) { e.printStackTrace(); } } // @Override // public void contextInitialized(ServletContextEvent servletContextEvent) { // try { // new Thread(new Runnable() { // @Override // public void run() { // try { // new NettyServer().bind(); // } catch (Exception e) { // e.printStackTrace(); // } // } // }).start(); // }catch(Exception e){ // e.printStackTrace(); // } // } // // @Override // public void contextDestroyed(ServletContextEvent servletContextEvent) { //// // } // public static void main(String[] args) throws Exception { new NettyServer().bind(); } } ``` 使用main方法启动服务在本地测试时是没错的,但是在tomcat部署后项目启动时,试过用Listener与Servlet去控制netty服务的初始化,都在启动时报错: ``` java.lang.NoSuchMethodError: io.netty.bootstrap.ServerBootstrap.channel(Ljava/lang/Class;)Lio/netty/bootstrap/ServerBootstrap; at cn.blue.netty.NettyServer.bind(NettyServer.java:39) at cn.blue.netty.NettyServer.init(NettyServer.java:68) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1282) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1195) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1085) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5318) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5610) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1863) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) ``` Spring:4.3.7.RELEASE Tomcat:7 JDK:1.8.0 netty:5.0.0.Alpha1 maven:3.3.9 求大神帮忙看看

作业中关于NullPointerException的问题?

我用的是Bluej ![图片说明](https://img-ask.csdn.net/upload/202003/30/1585571620_289719.png) 如图我用W.canTravel(1000,“ABC1“)函数运行正常,然后换一种方法用户输入 如图W.canTravel(i,i1)却显示NullPointerException。 ![图片说明](https://img-ask.csdn.net/upload/202003/30/1585572073_973885.png) 我Debug了一下当调用Scanner输入信息的时候S总是get不到值,值总是null,但是如果改成直接给两个如图1中W.canTravel(1000,“ABC1“),这样S却可以get到值,这是为什么?怎么解决? ![图片说明](https://img-ask.csdn.net/upload/202003/30/1585572259_281151.png) ![图片说明](https://img-ask.csdn.net/upload/202003/30/1585572280_865919.png)

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Vue + Spring Boot 项目实战(十九):Web 项目优化解决方案

快来一起探索如何打脸我们的破项目,兄弟姐妹们把害怕打在公屏上!

你连存活到JDK8中著名的Bug都不知道,我怎么敢给你加薪

CopyOnWriteArrayList.java和ArrayList.java,这2个类的构造函数,注释中有一句话 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 public ArrayList(Collection&lt;? ...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

CSDN:因博主近期注重写专栏文章(已超过150篇),订阅博主专栏人数在突增,近期很有可能提高专栏价格(已订阅的不受影响),提前声明,敬请理解!

CSDN:因博主近期注重写专栏文章(已超过150篇),订阅博主专栏人数在突增,近期很有可能提高专栏价格(已订阅的不受影响),提前声明,敬请理解! 目录 博客声明 大数据了解博主粉丝 博主的粉丝群体画像 粉丝群体性别比例、年龄分布 粉丝群体学历分布、职业分布、行业分布 国内、国外粉丝群体地域分布 博主的近期访问每日增量、粉丝每日增量 博客声明 因近期博主写专栏的文章越来越多,也越来越精细,逐步优化文章。因此,最近一段时间,订阅博主专栏的人数增长也非常快,并且专栏价

一个HashMap跟面试官扯了半个小时

一个HashMap能跟面试官扯上半个小时 关注 安琪拉的博客 1.回复面试领取面试资料 2.回复书籍领取技术电子书 3.回复交流领取技术电子书 前言 HashMap应该算是Java后端工程师面试的必问题,因为其中的知识点太多,很适合用来考察面试者的Java基础。 开场 面试官: 你先自我介绍一下吧! 安琪拉: 我是安琪拉,草丛三婊之一,最强中单(钟馗不服)!哦,不对,串场了,我是**,目...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

记录下入职中软一个月(外包华为)

我在年前从上一家公司离职,没想到过年期间疫情爆发,我也被困在家里,在家呆着的日子让人很焦躁,于是我疯狂的投简历,看面试题,希望可以进大公司去看看。 我也有幸面试了我觉得还挺大的公司的(虽然不是bat之类的大厂,但是作为一名二本计算机专业刚毕业的大学生bat那些大厂我连投简历的勇气都没有),最后选择了中软,我知道这是一家外包公司,待遇各方面甚至不如我的上一家公司,但是对我而言这可是外包华为,能...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

培训班出来的人后来都怎么样了?(二)

接着上回说,培训班学习生涯结束了。后面每天就是无休止的背面试题,不是没有头脑的背,培训公司还是有方法的,现在回想当时背的面试题好像都用上了,也被问到了。回头找找面试题,当时都是打印下来天天看,天天背。 不理解呢也要背,面试造飞机,上班拧螺丝。班里的同学开始四处投简历面试了,很快就有面试成功的,刚开始一个,然后越来越多。不知道是什么原因,尝到胜利果实的童鞋,不满足于自己通过的公司,嫌薪水要少了,选择...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

工作八年,月薪60K,裸辞两个月,投简历投到怀疑人生!

近日,有网友在某职场社交平台吐槽,自己裸辞两个月了,但是找工作却让自己的心态都要崩溃了,全部无果,不是已查看无回音,就是已查看不符合。 “工作八年,两年一跳,裸辞两个月了,之前月薪60K,最近找工作找的心态崩了!所有招聘工具都用了,全部无果,不是已查看无回音,就是已查看不符合。进头条,滴滴之类的大厂很难吗???!!!投简历投的开始怀疑人生了!希望 可以收到大厂offer” 先来看看网...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

都前后端分离了,咱就别做页面跳转了!统统 JSON 交互

文章目录1. 无状态登录1.1 什么是有状态1.2 什么是无状态1.3 如何实现无状态1.4 各自优缺点2. 登录交互2.1 前后端分离的数据交互2.2 登录成功2.3 登录失败3. 未认证处理方案4. 注销登录 这是本系列的第四篇,有小伙伴找不到之前文章,松哥给大家列一个索引出来: 挖一个大坑,Spring Security 开搞! 松哥手把手带你入门 Spring Security,别再问密...

97年世界黑客编程大赛冠军作品(大小仅为16KB),惊艳世界的编程巨作

这是世界编程大赛第一名作品(97年Mekka ’97 4K Intro比赛)汇编语言所写。 整个文件只有4095个字节, 大小仅仅为16KB! 不仅实现了3D动画的效果!还有一段震撼人心的背景音乐!!! 内容无法以言语形容,实在太强大! 下面是代码,具体操作看最后! @echo off more +1 %~s0|debug e100 33 f6 bf 0 20 b5 10 f3 a5...

程序员是做全栈工程师好?还是专注一个领域好?

昨天,有位大一的同学私信我,说他要做全栈工程师。 我一听,这不害了孩子么,必须制止啊。 谁知,讲到最后,更确定了他做全栈程序员的梦想。 但凡做全栈工程师的,要么很惨,要么很牛! 但凡很牛的,绝不是一开始就是做全栈的! 全栈工程师听起来好听,但绝没有你想象的那么简单。 今天听我来给你唠,记得帮我点赞哦。 一、全栈工程师的职责 如果你学习编程的目的只是玩玩,那随意,想怎么学怎么学。...

不要再到处使用 === 了

我们知道现在的开发人员都使用 === 来代替 ==,为什么呢?我在网上看到的大多数教程都认为,要预测 JavaScript 强制转换是如何工作这太复杂了,因此建议总是使用===。这些都...

什么是a站、b站、c站、d站、e站、f站、g站、h站、i站、j站、k站、l站、m站、n站?00后的世界我不懂!

A站 AcFun弹幕视频网,简称“A站”,成立于2007年6月,取意于Anime Comic Fun,是中国大陆第一家弹幕视频网站。A站以视频为载体,逐步发展出基于原生内容二次创作的完整生态,拥有高质量互动弹幕,是中国弹幕文化的发源地;拥有大量超粘性的用户群体,产生输出了金坷垃、鬼畜全明星、我的滑板鞋、小苹果等大量网络流行文化,也是中国二次元文化的发源地。 B站 全称“哔哩哔哩(bilibili...

十个摸鱼,哦,不对,是炫酷(可以玩一整天)的网站!!!

文章目录前言正文**1、Kaspersky Cyberthreat real-time map****2、Finding Home****3、Silk – Interactive Generative Art****4、Liquid Particles 3D****5、WINDOWS93****6、Staggering Beauty****7、Ostagram图片生成器网址****8、全历史网址*...

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

用了这个 IDE 插件,5分钟解决前后端联调!

点击上方蓝色“程序猿DD”,选择“设为星标”回复“资源”获取独家整理的学习资料!作者 |李海庆我是一个 Web 开发前端工程师,受到疫情影响,今天是我在家办公的第78天。开发了两周,...

大厂的 404 页面都长啥样?最后一个笑了...

每天浏览各大网站,难免会碰到404页面啊。你注意过404页面么?猿妹搜罗来了下面这些知名网站的404页面,以供大家欣赏,看看哪个网站更有创意: 正在上传…重新上传取消 腾讯 正在上传…重新上传取消 网易 淘宝 百度 新浪微博 正在上传…重新上传取消 新浪 京东 优酷 腾讯视频 搜...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

Java14 新特性解读

Java14 已于 2020 年 3 月 17 号发布,官方特性解读在这里:https://openjdk.java.net/projects/jdk/14/以下是个人对于特性的中文式...

前端还能这么玩?(女朋友生日,用前端写了一个好玩的送给了她,高兴坏了)

前端还能这么玩?(女朋友生日,用前端写了一个好玩的送给了她,高兴坏了)

爬虫(101)爬点重口味的

小弟最近在学校无聊的很哪,浏览网页突然看到一张图片,都快流鼻血。。。然后小弟冥思苦想,得干一点有趣的事情python 爬虫库安装https://s.taobao.com/api?_ks...

工作两年简历写成这样,谁要你呀!

作者:小傅哥 博客:https://bugstack.cn 沉淀、分享、成长,让自己和他人都能有所收获! 一、前言 最近有伙伴问小傅哥,我的简历怎么投递了都没有反应,心里慌的很呀。 工作两年了目前的公司没有什么大项目,整天的维护别人的代码,有坑也不让重构,都烦死了。荒废我一身技能无处施展,投递的简历也没人看。我是不动物园里的猩猩,狒狒了! 我要加班,我要996,我要疯狂编码,求给我个机会… ...

相关热词 c# 开发接口 c# 中方法上面的限制 c# java 时间戳 c#单元测试入门 c# 数组转化成文本 c#实体类主外键关系设置 c# 子函数 局部 c#窗口位置设置 c# list 查询 c# 事件 执行顺序
立即提问
相关内容推荐